├── README.md ├── features ├── AndroidFeature.feature └── IOSFeature.feature ├── pavement.py ├── requirements.txt └── steps ├── AndroidStepDef.py ├── IosStepDef.py └── appConfig.py /README.md: -------------------------------------------------------------------------------- 1 | # How to install multiple apps in Real Devices on [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python-behave-multipleApps) using the Appium Python Behave Framework 2 | 3 | While performing app automation testing with appium on LambdaTest Grid, you might face a scenario where the APP1 that you are testing needs to interact with a few other applications APP2, APP3. In this scenario, LambdaTest offers an easy way out where you can just [upload your apps](https://www.lambdatest.com/support/docs/appium-java/#upload-your-application) & add them to the multiple apps array. 4 | It becomes extremely convenient now where you can just add those URLs & run your tests with ease. 5 | 6 | # Steps: 7 | 8 | You can add the app URLs fetched by [uploading your apps](https://www.lambdatest.com/support/docs/appium-java/#upload-your-application) in the ```otherApps``` capability. 9 | 10 | 11 | ``` 12 | app_android_desired_caps = { 13 | "deviceName":"Galaxy S20", 14 | "platformName":"Android", 15 | "platformVersion":"10", 16 | "build":"Python Behave - Android", 17 | "name":"Sample Test Android", 18 | "isRealMobile":True, 19 | "network":True, 20 | "visual":True, 21 | "video":True, 22 | "app":"lt://", #Enter app_url here 23 | 24 | 25 | # ADD THE APP URL OF OTHER APPS THAT YOU'D LIKE TO INSTALL ON THE SAME DEVICE 26 | 27 | "otherApps":["lt:// ", "lt:// "] #ENTER THE OTHER APP URLs HERE IN AN ARRAY FORMAT 28 | 29 | 30 | } 31 | 32 | app_ios_desired_caps = { 33 | "deviceName":"iPhone 12", 34 | "platformName":"ios", 35 | "platformVersion":"14", 36 | "build":"Python Behave - iOS", 37 | "name":"Sample Test iOS", 38 | "isRealMobile":True, 39 | "network":True, 40 | "visual":True, 41 | "video":True, 42 | "app":"lt://", #Enter app_url here 43 | 44 | 45 | # ADD THE APP URL OF OTHER APPS THAT YOU'D LIKE TO INSTALL ON THE SAME DEVICE 46 | 47 | "otherApps":["lt:// ", "lt:// "] #ENTER THE OTHER APP URLs HERE IN AN ARRAY FORMAT 48 | 49 | } 50 | 51 | ``` 52 | 53 | ## Run your test 54 | 55 | ```bash 56 | python3 android.py 57 | ``` 58 | 59 | Your test results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on the [LambdaTest App Automation Dashboard](https://appautomation.lambdatest.com/build). 60 | 61 | ## Additional Links 62 | 63 | - [Advanced Configuration for Capabilities](https://www.lambdatest.com/support/docs/desired-capabilities-in-appium/) 64 | - [How to test locally hosted apps](https://www.lambdatest.com/support/docs/testing-locally-hosted-pages/) 65 | - [How to integrate LambdaTest with CI/CD](https://www.lambdatest.com/support/docs/integrations-with-ci-cd-tools/) 66 | 67 | ## Documentation & Resources :books: 68 | 69 | Visit the following links to learn more about LambdaTest's features, setup and tutorials around test automation, mobile app testing, responsive testing, and manual testing. 70 | 71 | * [LambdaTest Documentation](https://www.lambdatest.com/support/docs/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python) 72 | * [LambdaTest Blog](https://www.lambdatest.com/blog/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python) 73 | * [LambdaTest Learning Hub](https://www.lambdatest.com/learning-hub/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python) 74 | * [LambdaTest Community](http://community.lambdatest.com/) 75 | 76 | ## LambdaTest Community :busts_in_silhouette: 77 | 78 | The [LambdaTest Community](https://community.lambdatest.com/) allows people to interact with tech enthusiasts. Connect, ask questions, and learn from tech-savvy people. Discuss best practises in web development, testing, and DevOps with professionals from across the globe 🌎 79 | 80 | ## What's New At LambdaTest ❓ 81 | 82 | To stay updated with the latest features and product add-ons, visit [Changelog](https://changelog.lambdatest.com/) 83 | 84 | ## About LambdaTest 85 | 86 | [LambdaTest](https://www.lambdatest.com) is a leading test execution and orchestration platform that is fast, reliable, scalable, and secure. It allows users to run both manual and automated testing of web and mobile apps across 3000+ different browsers, operating systems, and real device combinations. Using LambdaTest, businesses can ensure quicker developer feedback and hence achieve faster go to market. Over 500 enterprises and 1 Million + users across 130+ countries rely on LambdaTest for their testing needs. 87 | 88 | ### Features 89 | 90 | * Run Selenium, Cypress, Puppeteer, Playwright, and Appium automation tests across 3000+ real desktop and mobile environments. 91 | * Real-time cross browser testing on 3000+ environments. 92 | * Test on Real device cloud 93 | * Blazing fast test automation with HyperExecute 94 | * Accelerate testing, shorten job times and get faster feedback on code changes with Test At Scale. 95 | * Smart Visual Regression Testing on cloud 96 | * 120+ third-party integrations with your favorite tool for CI/CD, Project Management, Codeless Automation, and more. 97 | * Automated Screenshot testing across multiple browsers in a single click. 98 | * Local testing of web and mobile apps. 99 | * Online Accessibility Testing across 3000+ desktop and mobile browsers, browser versions, and operating systems. 100 | * Geolocation testing of web and mobile apps across 53+ countries. 101 | * LT Browser - for responsive testing across 50+ pre-installed mobile, tablets, desktop, and laptop viewports 102 | 103 | [](https://accounts.lambdatest.com/register) 104 | 105 | ## We are here to help you :headphones: 106 | 107 | * Got a query? we are available 24x7 to help. [Contact Us](support@lambdatest.com) 108 | * For more info, visit - [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=LT-appium-python-behave-multipleApps) 109 | -------------------------------------------------------------------------------- /features/AndroidFeature.feature: -------------------------------------------------------------------------------- 1 | Feature: Android real device app and web automation 2 | 3 | @androidApp 4 | Scenario: Android real device app automation 5 | Given Start the android app automation test -------------------------------------------------------------------------------- /features/IOSFeature.feature: -------------------------------------------------------------------------------- 1 | Feature: IOS real device web and app automation 2 | 3 | @iosApp 4 | Scenario: Android real device app automation 5 | Given Start the ios app automation test -------------------------------------------------------------------------------- /pavement.py: -------------------------------------------------------------------------------- 1 | from paver.easy import * 2 | from paver.setuputils import setup 3 | import multiprocessing 4 | import json 5 | import os 6 | 7 | setup( 8 | name="python-behave-proverbial", 9 | packages=['features'], 10 | version="1.0.0", 11 | url="https://www.lambdatest.com/", 12 | author="Lambdatest", 13 | description=("Behave Integration with Lambdatest"), 14 | license="MIT", 15 | author_email="support@lambdatest.com" 16 | ) 17 | 18 | 19 | def run_behave_test(env, index=0): 20 | """ 21 | runs the individual test 22 | :param env: 23 | :param index: 24 | :return: 25 | """ 26 | if env == "jenkins": 27 | sh('INDEX=%s env=%s behave features/test.feature ' % (index, env,)) 28 | else: 29 | sh('INDEX=%s env=%s behave features/test.feature ' % (index, env,)) 30 | 31 | 32 | @task 33 | @consume_args 34 | def run(args): 35 | """ 36 | runs the behave test 37 | :return: 38 | """ 39 | env = args[0] if len(args) > 0 else "" 40 | jobs = [] 41 | pool = get_pool_size() 42 | for i in range(pool): 43 | p = multiprocessing.Process(target=run_behave_test, args=(env, i,)) 44 | jobs.append(p) 45 | p.start() 46 | 47 | 48 | def get_pool_size(): 49 | """ 50 | sets the number of parallel test 51 | :return: 52 | """ 53 | if "LT_BROWSERS" in os.environ: 54 | CONFIG = json.loads(os.environ["LT_BROWSERS"]) 55 | pool = len(CONFIG) 56 | else: 57 | json_file = "config/config.json" 58 | with open(json_file) as data_file: 59 | CONFIG = json.load(data_file) 60 | pool = len(CONFIG) 61 | return pool 62 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Paver==1.3.4 2 | selenium 3 | behave==1.2.6 4 | Appium-Python-Client -------------------------------------------------------------------------------- /steps/AndroidStepDef.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | path = os.getcwd() 4 | sys.path.append(os.path.abspath(os.path.join(path, os.pardir))) 5 | from time import time 6 | from behave import given 7 | from appium import webdriver 8 | import appConfig as appConf 9 | from appium.webdriver.common.mobileby import MobileBy 10 | from selenium.webdriver.support.ui import WebDriverWait 11 | from selenium.webdriver.support import expected_conditions as EC 12 | 13 | @given("Start the android app automation test") 14 | def startAndroidAppAutomationTest(self): 15 | if os.environ.get("LT_USERNAME") is None: 16 | username = "username" #Enter LT username here if environment variables have not been added 17 | else: 18 | username = os.environ.get("LT_USERNAME") 19 | if os.environ.get("LT_ACCESS_KEY") is None: 20 | accesskey = "accesskey" #Enter LT accesskey here if environment variables have not been added 21 | else: 22 | accesskey = os.environ.get("LT_ACCESS_KEY") 23 | 24 | driver = webdriver.Remote( 25 | command_executor="https://"+username+":"+accesskey+"@beta-hub.lambdatest.com/wd/hub", 26 | desired_capabilities=appConf.app_android_desired_caps 27 | ) 28 | try: 29 | colorElement = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ID,"com.lambdatest.proverbial:id/color"))) 30 | colorElement.click() 31 | 32 | textElement = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ID,"com.lambdatest.proverbial:id/Text"))) 33 | textElement.click() 34 | 35 | toastElement = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ID,"com.lambdatest.proverbial:id/toast"))) 36 | toastElement.click() 37 | 38 | notification = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ID,"com.lambdatest.proverbial:id/notification"))) 39 | notification.click() 40 | 41 | geolocation = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ID,"com.lambdatest.proverbial:id/geoLocation"))) 42 | geolocation.click() 43 | 44 | home = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ID,"com.lambdatest.proverbial:id/Home"))) 45 | home.click() 46 | 47 | driver.quit() 48 | except: 49 | driver.quit() 50 | -------------------------------------------------------------------------------- /steps/IosStepDef.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | path = os.getcwd() 4 | sys.path.append(os.path.abspath(os.path.join(path, os.pardir))) 5 | import appConfig as appConf 6 | from behave import given 7 | from appium import webdriver 8 | import time 9 | from appium.webdriver.common.mobileby import MobileBy 10 | from selenium.webdriver.support.ui import WebDriverWait 11 | from selenium.webdriver.support import expected_conditions as EC 12 | 13 | @given("Start the ios app automation test") 14 | def startIOSAppAutomationTest(self): 15 | if os.environ.get("LT_USERNAME") is None: 16 | username = "username" #Enter LT username here if environment variables have not been added 17 | else: 18 | username = os.environ.get("LT_USERNAME") 19 | if os.environ.get("LT_ACCESS_KEY") is None: 20 | accesskey = "accesskey" #Enter LT accesskey here if environment variables have not been added 21 | else: 22 | accesskey = os.environ.get("LT_ACCESS_KEY") 23 | 24 | driver = webdriver.Remote( 25 | command_executor="https://"+username+":"+accesskey+"@beta-hub.lambdatest.com/wd/hub", 26 | desired_capabilities=appConf.app_ios_desired_caps 27 | ) 28 | try: 29 | colorElement = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID,"color"))) 30 | colorElement.click() 31 | 32 | textElement = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID,"Text"))) 33 | textElement.click() 34 | 35 | toastElement = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID,"toast"))) 36 | toastElement.click() 37 | 38 | notification = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID,"notification"))) 39 | notification.click() 40 | time.sleep(3) 41 | 42 | geolocation = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID,"geoLocation"))) 43 | geolocation.click() 44 | time.sleep(3) 45 | 46 | home = WebDriverWait(driver,20).until(EC.element_to_be_clickable((MobileBy.ACCESSIBILITY_ID,"Back"))) 47 | home.click() 48 | 49 | driver.quit() 50 | except: 51 | driver.quit() 52 | -------------------------------------------------------------------------------- /steps/appConfig.py: -------------------------------------------------------------------------------- 1 | app_android_desired_caps = { 2 | "deviceName":"Galaxy S20", 3 | "platformName":"Android", 4 | "platformVersion":"10", 5 | "build":"Python Behave - Android", 6 | "name":"Sample Test Android", 7 | "isRealMobile":True, 8 | "network":True, 9 | "visual":True, 10 | "video":True, 11 | "app":"lt://", #Enter app_url here 12 | 13 | 14 | # ADD THE APP URL OF OTHER APPS THAT YOU'D LIKE TO INSTALL ON THE SAME DEVICE 15 | 16 | "otherApps":["lt:// ", "lt:// "] #ENTER THE OTHER APP URLs HERE IN AN ARRAY FORMAT 17 | 18 | 19 | } 20 | 21 | app_ios_desired_caps = { 22 | "deviceName":"iPhone 12", 23 | "platformName":"ios", 24 | "platformVersion":"14", 25 | "build":"Python Behave - iOS", 26 | "name":"Sample Test iOS", 27 | "isRealMobile":True, 28 | "network":True, 29 | "visual":True, 30 | "video":True, 31 | "app":"lt://", #Enter app_url here 32 | 33 | 34 | # ADD THE APP URL OF OTHER APPS THAT YOU'D LIKE TO INSTALL ON THE SAME DEVICE 35 | 36 | "otherApps":["lt:// ", "lt:// "] #ENTER THE OTHER APP URLs HERE IN AN ARRAY FORMAT 37 | 38 | } 39 | --------------------------------------------------------------------------------