Skip to content

Appium python: Not able to run parallel execution in two android real devices, test run only in one device, However, script could only launch app in other device #484

@ather-ctrl

Description

@ather-ctrl

Hi Appium users and team
I am trying to run below script in two real android devices for simple calculator test parallel.
Issue : My script is only being executed in one devices, only launching the application in other device with no actions at all. not executing it parallel. script doesn't throw error.

Created the two instances in command prompt with below commands:

appium -U "device id" -p 4723
appium -U "device id" -p 4733

After referring to various answers, got to know i need to use arg parse for parallel execution but dont know how easy it is. how feasible it is. https://docs.python.org/3/howto/argparse.html#id1
Not sure if i can use multi-threading module in python or not.

@appium Team, I am using appium with pycharm ide and HTML test runner for test results(Linux). Could you please suggest or modify below code. What is exact way to to run execution in parallel. I could find so many Java related examples but could not figures out how to convert the code in python.
Very less example are available for parallel in python. Please help.

Refered Links but could not figured out solution:

#138 (comment)
http://www.automationtestinghub.com/appium-parallel-execution/

import unittest
from appium import webdriver
import time

class AndroidCalculatorTest(unittest.TestCase):
def setUp(self):

    #Real Device #1
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '9'
    desired_caps['deviceName'] = '21d873202904XXX'
    desired_caps['noReset'] = 'true'
    desired_caps['appPackage'] = 'com.sec.android.app.popupcalculator'
    desired_caps['appActivity'] = 'com.sec.android.app.popupcalculator.Calculator'
    self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

    #Real Device 2
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '9'
    desired_caps['deviceName'] = 'f2XXXX'
    desired_caps['noReset'] = 'true'
    desired_capss['appPackage'] = 'com.sec.android.app.popupcalculator'
    desired_capss['appActivity'] = 'com.sec.android.app.popupcalculator.Calculator'
    self.driver1 = webdriver.Remote('http://localhost:4733/wd/hub', desired_caps)

def tearDown(self):
    self.driver.quit()

def test_text_friend(self):
    self.driver.find_element_by_id("com.sec.android.app.popupcalculator:id/bt_05").click()
    self.driver.find_element_by_id("com.sec.android.app.popupcalculator:id/bt_add").click()
    self.driver.find_element_by_id("com.sec.android.app.popupcalculator:id/bt_06").click()
    self.driver.find_element_by_id("com.sec.android.app.popupcalculator:id/bt_equal").click()
    candy = self.driver.find_element_by_id("com.sec.android.app.popupcalculator:id/txtCalc").text
    self.assertEqual("11", candy), "Element not found"

if name == 'main':
suite = unittest.TestLoader().loadTestsFromTestCase(AndroidCalculatorTest)
unittest.TextTestRunner(verbosity=2).run(suite)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions