如果RDP从未连接到Jenkins奴隶,则IE的硒悬浮动作将不起作用 [英] Selenium hover action with IE doesn't work if RDP never connected to Jenkins slaves
问题描述
我们在Amazon EC2上创建了一堆Windows Jenkins奴隶,并使其成为设置后自动登录.
登录后,我们通过执行"ps"通过java web start将从服务器连接回主服务器,所有这些,我们都可以使用IE完美地运行硒,除非我们无法获得比1024 * 768更高的分辨率.我们得到了屏幕截图,如果与RDP连接,我们可以看到浏览器在GUI上运行,就像在物理PC上运行一样.
但是一个缺点是,除非我们在测试开始前一次通过远程桌面连接到从属服务器,否则仅在连接IE上不起作用,只需连接一次,我什至不能关闭RDP会话.
/p>
我猜是由RDP连接触发的,只是无法弄清楚那是什么.
如果没有,则可以尝试调整测试脚本以使其在开始测试之前建立RDP连接.这是我用于我们的项目之一的代码,以确保RDP连接处于活动状态:
REM check if user has an RDP session. Will store the session ID of the user in the SESSION variable
call :getsession computername username SESSION
if "%SESSION%" EQU "" (
REM initiate an RDP connection to 'computername', wait, and disconnect by killing the process
mstsc.exe /v:computername & ping -n 5 1.1.1.1 & taskkill /F /IM mstsc.exe
)
REM check again the session
call :getsession computername user SESSION
if %SESSION% NEQ "" (
echo start your tests
)
:getsession
for /F "tokens=1,2,3,4" %%i in ('query session /SERVER:%1 ^| findstr %2') do if %%j EQU %2 (SET %3=%%k) else (SET %3=%%j)
goto :eof
请注意,只有在将凭据保存到启动远程桌面的计算机上时,才会建立自动连接:
cmdkey /generic:computername /user:rdp_username /pass:rdp_password
执行一次此操作后,mstsc.exe将能够在没有用户交互的情况下连接到计算机.
We create a bunch of windows Jenkins slaves on Amazon EC2, and make them autologon after they are provisioned.
Once logged on, we use connect the slaves back to master via java web start by execute "ps", with all of this, we can run selenium perfectly with IE except we can't get a higher resolution than 1024*768. We got screenshot, we can see the browser running on the GUI if connected with RDP, just like running on a physical PC.
But a flaw is that, the hover action doesn't work on IE unless we connect to the slave through remote desktop one time before the test starts, just connect once, nothing else, I can even close the RDP session.
I guess something triggered by the RDP connection, just can't figure out what is that.
You can try to adapt your test scripts to have them make an RDP connection before you start your tests, if there is none. This is the code I used for one of our projects to ensure an RDP connection is active:
REM check if user has an RDP session. Will store the session ID of the user in the SESSION variable
call :getsession computername username SESSION
if "%SESSION%" EQU "" (
REM initiate an RDP connection to 'computername', wait, and disconnect by killing the process
mstsc.exe /v:computername & ping -n 5 1.1.1.1 & taskkill /F /IM mstsc.exe
)
REM check again the session
call :getsession computername user SESSION
if %SESSION% NEQ "" (
echo start your tests
)
:getsession
for /F "tokens=1,2,3,4" %%i in ('query session /SERVER:%1 ^| findstr %2') do if %%j EQU %2 (SET %3=%%k) else (SET %3=%%j)
goto :eof
Note that the automatic connection will only be made if you save credentials on the machine from which you start the remote desktop:
cmdkey /generic:computername /user:rdp_username /pass:rdp_password
After executing this once the mstsc.exe will be able to connect to the machine without user interaction.
这篇关于如果RDP从未连接到Jenkins奴隶,则IE的硒悬浮动作将不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!