selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Internet Explorer WebDriver not working after remote desktop connection is closed

Open daviande opened this issue 11 years ago • 7 comments

Our Setup:

  1. Testing Internet Explorer on Windows Server 2012 R2 running in an AWS Instance
  2. Using WebDriverJS with Native Events enabled

Issue Observed: If I use Remote Desktop to connect to the AWS instance and then disconnect from the AWS instance, I can no longer run automation successfully. A number of the WebDriver actions (sendKeys, mouseMove, etc) appear to fail silently. The command succeeds (promise chain completes without error), but no sendKeys, mouseMove, etc action is taken. If I (1) Remote desktop back to the machine and watch automation run or (2) reboot machine and run automation via Jenkins without using Remote desktop, then the automation will succeed.

Repro steps:

  1. Reboot Amazon AWS Instance (Windows Server 2012 R2)
  2. Run automation via Jenkins
  3. Automation succeeds
  4. Remote desktop to AWS Instance
  5. Close Remote desktop session
  6. Rerun automation via Jenkins
  7. Automation silently fails when attempting to use sendKeys, mouseMove, etc. But, url navigation appears to still work.

Are there any known issues around IE, WebDriverJS, native events, remote desktop, etc?

daviande avatar Jul 09 '15 21:07 daviande

@daviande, That should be expected. When you RD into your machine, you create a new session with the machine. This session has desktop and other resource access. You initiate your automation inside that session. When you disconnect, that session is kept running, but it is as good as a locked screen desktop. Now any kind of sendKeys of mouseMoves on a locked desktop will never reach an application. And that is what is happening in your case. If you are really looking to remote into your machine, then you should be using something like TeamViewer or RemoteVNC on the windows machine. They connect to the main desktop session and don't create an additional session like Remote Desktop

tarunlalwani avatar Jul 10 '15 05:07 tarunlalwani

Also you can try using below and see if that helps

mstsc /console

This may help you connect to the console session. Not sure if that would work, but you can give it a shot

tarunlalwani avatar Jul 10 '15 05:07 tarunlalwani

@talabs I'm afaraid /console no longer works in WS 2012 (http://serverfault.com/questions/677592/connecting-to-windows-server-2012-r2-console-session-with-rdp).

@daviande You say that this works when you "reboot machine and run automation via Jenkins without using Remote desktop". Can you elaborate on how you run the Jenkins/Selenium in this setup? In my experience (Jenkins as a service, Selenium server started from Task Schduler) this works only for some time until Windows decides to make the session idle or something. The only working setup I was able to create is using VNC to run the Server on "real desktop" session.

lqc avatar Jul 10 '15 07:07 lqc

Try redirecting your RDP session to console instead of disconnecting the usual way. This should prevent the session from getting locked.

tscon SESSION_ID /dest:console

romovs avatar Jul 10 '15 07:07 romovs

Everyone, thanks for the help. We were able to sort this out by running following bat script at beginning of Jenkins run:

for /f %%i in ('qwinsta ^| findstr ">rdp-tcp#"') do set RDP_SESSION=%%i :: Strip the > set RDP_SESSION=%RDP_SESSION:>=% tscon %RDP_SESSION% /dest:console echo y | rwinsta 65536

daviande avatar Jul 14 '15 22:07 daviande

@daviande, thanks for sharing this :-)

tarunlalwani avatar Jul 15 '15 13:07 tarunlalwani

Hi @daviande Could you describe you command in more details. for /f %%i in ('qwinsta ^| findstr ">rdp-tcp#"') do set RDP_SESSION=%%i :: Strip the > set RDP_SESSION=%RDP_SESSION:>=% tscon %RDP_SESSION% /dest:console echo y | rwinsta 65536 I have similar problems with TestCafe, that works locally when user logged in, but not works using PowerShell Remote Session.

ghost avatar Nov 15 '17 08:11 ghost