Brief background:
- Automating a winform application using WInAppDriver/Appium.
- Using Specflow's BDD to define tests
- At every start of test the automation test will always check if App is open already, if not, then fire-up/initialised application - See
InitializedAppium(string application)
in screenshot below. - In that
InitializedAppium(string application)
we create "a new instance of the WindowsDriver class using the specified remote address and Appium options". - The line;
var newDriver = new WindowsDriver<AppiumWebElement>(new Uri("http://127.0.0.1:4723/"), driverOptions);
sometimes it throws that intermittent error, and sometimes it don't (mostly the former). - Using WinAppDriver & ChromeDriver to execute test.
- First of all, when running the test locally, everything works flawlessly (at least opening up the App)
- Secondly, my intermittent issue happening when I'm running the test using the DevOps MS Hosted Agent machine in our pipeline.
Specific error received:
OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://127.0.0.1:4723/session timed out after 60 seconds. ---> System.Net.WebException: The operation has timed out
What lead to the error:
Trying to fire-up the application! using the following;
DebugOutput.Log($"Starting {application}"); var driverOptions = new AppiumOptions(); DebugOutput.Log($"NEW {application}"); driverOptions.AddAdditionalCapability(MobileCapabilityType.App, application); driverOptions.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, 500); driverOptions.AddAdditionalCapability("appium:createSessionTimeout", "20000"); //you may shorten this (<25s) if testing locally, but remember to change it back again) driverOptions.AddAdditionalCapability("ms:waitForAppLaunch", "50"); DebugOutput.Log($"CAPS {application}"); // this is where the failure most times happen when cannot initiate app var newDriver = new WindowsDriver<AppiumWebElement>(new Uri("http://127.0.0.1:4723/"), driverOptions); DebugOutput.Log($"Window Driver Succeeded = {newDriver}"); return newDriver;
screenshot legends:
- Step into InitializeAppium
- The InitializeAppium method
- create "a new instance of the WindowsDriver class using the specified remote address and Appium options". This is very much the centre of the question.
- debug log when it failed
- debug log when it passes
- DevOps pipeline between pass and fail with the same exact test (intermittent issue)
- The specific error I got when I took out the try and catch statement.
Is there more Additional Capabilities I should add to the AppiumOptions to prevent this timeout...its annoying because it seems that this is the only major issue I am having when running it it in the hosted agent machine!
Any help much appreciated as i'm at the end point where I have no clue what else I can do. If you need need more info to help me, let me know.
Regards,
B