question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parallel Execution, Appium hangs on first command (after driver init)

See original GitHub issue

The problem

Working fine on one device, but hangs forever on the first command with two or more. Example commands that hang for 60 seconds… is this because of parallel execution? How to work around

  • getDeviceSize()
  • element.Click()
  • findElementsById()

Environment

  • Appium 1.6.5
  • Windows/Linux

Link to Appium logs

https://gist.github.com/gamesguru/7b740c93ea0683962006765699fe87bb

Code To Reproduce Issue [ Good To Have ]


 private void Bw_DoWork(object sender, DoWorkEventArgs e)
        {
            int i = 0;
            foreach (string serial in nativeFuncs.initialSerials)
            {
                nativeFuncs.statusDict[serial] = "loading";
                nativeFuncs.appiumLogDict[serial] = "...starting appium...\n";
                nativeFuncs.portDict[serial] = 4723 + i;
                comboBox1.Items.Add(serial);
                i++;
            }
            //comboBox1.SelectedIndex = 0;
            nativeFuncs.setDevStats();
                     

            //runs the main tests
            Parallel.For(0, nativeFuncs.initialSize, new ParallelOptions { MaxDegreeOfParallelism = 4 }, z =>
            {
                string s = nativeFuncs.initialSerials[z];
                pReader.cmd($"/c appium -a 127.0.0.1 -p {nativeFuncs.portDict[s].ToString()}", s, true);

                DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.SetCapability("udid", s);                                  //serial
                capabilities.SetCapability("deviceName", nativeFuncs.devNameDict[s]);   //SM-J327P (aka productModel)
                capabilities.SetCapability("appPackage", appPackage);
                capabilities.SetCapability("appActivity", appActivity);
                capabilities.SetCapability(MobileCapabilityType.NoReset, true);
                capabilities.SetCapability(MobileCapabilityType.FullReset, false);

                nativeFuncs.cmdWorkerDict[s].RunWorkerAsync();
                nativeFuncs.selfLogDict[s] += "starting appium log..\n";
                nativeFuncs.selfLogDict[s] += $"on port {nativeFuncs.portDict[s].ToString()}..\n";
                nativeFuncs.statusDict[s] = "Starting";
                try { nativeFuncs.driverDict[s] = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:" + nativeFuncs.portDict[s].ToString() + "/wd/hub"), capabilities); }
                catch (Exception ex) { nativeFuncs.selfLogDict[s] += printE(ex); }
                AndroidDriver<AndroidElement> driver = nativeFuncs.driverDict[s];
                if (driver == null)
                {
                    nativeFuncs.appiumLogDict[s] += "\n\nAppium failed to connect..";
                    //nativeFuncs.s
                    return;
                }

                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);

                //grabs screen size
                //nativeFuncs.hDict[s] = driver.Manage().Window.Size.Height;
                //nativeFuncs.wDict[s] = driver.Manage().Window.Size.Width;
                //nativeFuncs.yDict[s] = nativeFuncs.hDict[s] / 2;
                //nativeFuncs.xDict[s] = nativeFuncs.wDict[s] / 2;

                //nativeFuncs.selfLogDict[s] += $"Height: {nativeFuncs.hDict[s]}, Width: {nativeFuncs.wDict[s]}";
                //Thread.Sleep(700);

                nativeFuncs.selfLogDict[s] += "\nAppium started, logging into OneControl...";
                nativeFuncs.statusDict[s] = "First run";
                nativeFuncs.setDevStats();

                if (!nativeFuncs.devNameDict[s].Contains("OCTP"))
                    testMethods.pinScreen(s);

                testMethods.TestLighting(s);
            });

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
mykola-mokhnachcommented, Nov 2, 2017

@gamesguru Have you eventually read https://github.com/appium/appium/blob/55760b7b9e1c494c6a1f22d152f0bd1fe676dae7/docs/en/advanced-concepts/parallel-tests.md ?

To me it looks like both sessions still try to use the same port and the tutorial explicitly states

systemPort If you are using appium-uiautomator2-driver, set a different system port for each Appium instanceset with systemPort capability since sometimes there can be a port conflict if different ports aren’t used, such as in this issue.

0reactions
lock[bot]commented, Apr 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting - Appium
Make sure developer mode is on · Make sure command prompt is Admin · Check that the URL Appium server is listening to...
Read more >
Appium Parallel Execution - Issues/Bugs
I am starting the appium server using the following code snippet and it works fine: @BeforeTest public void appstart() { AppiumDriverLocalService service ...
Read more >
Appium Session Issue - Support
My all test cases not executed. It executed in the following manner 1 3 5. it will terminate the session for 2 and...
Read more >
Desired Capabilities - Appium
Capabilities also differ by driver, though there are a standard set that most ... This capability can speed up test execution, since Accessibility...
Read more >
Facing issue in Parallel execution for multiple devices - Support
After executing script through TestNG my test script is successfully running in one device but for other device I am getting below error....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found