执行AutoIt脚本后将控制权返回给Selenium [英] Return control to Selenium after executing an AutoIt script

查看:121
本文介绍了执行AutoIt脚本后将控制权返回给Selenium的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写Selenium脚本来测试我的网页.为了模拟测试,桌面应用程序会在数据库中重置日期(因为更改日期后将运行实际过程).

I am writing Selenium scripts to test my webpage. To simulate testing, a desktop application resets the date in the DB (as the actual process is run after the date changes).

现在,我可以调用我的应用程序,并按Runtime.getRuntime().exec("E:\\AutoIT\\DBReset.exe");键通过Selenium单击按钮,但是在完成重置后,我无法将控件返回给Selenium.

Now I am able to call my application and click the button through Selenium by Runtime.getRuntime().exec("E:\\AutoIT\\DBReset.exe");, but I am unable to return the control to Selenium after the reset is done.

推荐答案

通过 AutoIt 使用以下命令执行操作时:

When you perform the operation by AutoIt using:

Runtime.getRuntime().exec("E:\AutoIT\DBReset.exe");

Selenium仍然将焦点放在网页上.因此,一旦 Windows对话框关闭,Selenium应该能够执行下一行代码.

Selenium still holds the focus to the web page. So once the Windows dialog box closes, Selenium should be able to execute the next line of code.

如果抱怨失去焦点,您可以使用JavascriptExecutor来获得浏览器的焦点:

In case Selenium complains of lost focus you can use JavascriptExecutor to gain back browser focus :

  • Java:

  • Java :

((JavascriptExecutor) driver).executeScript("window.focus();");

这篇关于执行AutoIt脚本后将控制权返回给Selenium的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆