appium: Parallel Execution, Appium hangs on first command (after driver init)
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);
});
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 20 (4 by maintainers)
@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