问题
I have a Selenium test which would fail when run as part of a Jenkins job on a node hosted in vSphere and administered through RDP. The test are run with IE11.
After some troubleshooting it turned out it succeeds if Remote Desktop is connected and focused but fails with an exception if Remote Desktop is disconnected or even minimized:
OneTimeSetUp: OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:56095/session/817b36df-a1b5-484e-b205-d4a0bac8002a/element/0cfa6678-2104-4bc6-bb71-e6d8eac507fb/value timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
The failing line:
textboxElement.SendKeys("foo").Perform();
As a workaround, I logged through vSphere Console instead of RDP and then even after closing vSphere the test didn't fail anymore. This is a workaround but I would have to be careful never to login through RDP and always to administer only through vSphere Console.
So my questions are:
- Is
SendKeys()
somehow incompatible with an RDP session and is it related to this winapi bug? - Is there an alternative to using
SendKeys()
in Selenium?
回答1:
When you execute the selenium script without any UI environment bind to the process the size of the Chrome window may be different from when you execute it when you are logged in with RemoteDesktop.
Try to explicitly set window size in the selenium script prior to the failing command. 1) try some small width/height and execute it where the script usually succeeds, and see what happens 2) set to some large value and execute it on Jenkins, where it usually fails.
回答2:
Found the culprit - there was a flag RequireWindowFocus = true
in InternetExplorerOptions
which was causing the issue. After removing it I no longer get the error. This might be related to https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/5431.
来源:https://stackoverflow.com/questions/55615331/remote-desktop-selenium-and-sendkeys-webdriver-server-timed-out-after-60-secon