Selenium: Internet Explorer WebDriver not working after remote desktop connection is closed

Created on 9 Jul 2015  路  7Comments  路  Source: SeleniumHQ/selenium

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?

Most helpful comment

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

All 7 comments

@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

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

@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.

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

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, thanks for sharing this :-)

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.

Was this page helpful?
0 / 5 - 0 ratings