如何通过RemoteWebDriver完全关闭Opera浏览器 [英] How to fully close Opera browser via RemoteWebDriver

查看:171
本文介绍了如何通过RemoteWebDriver完全关闭Opera浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将Opera添加到Selenium Grid上的一个节点上,但是在关闭Opera浏览器时遇到问题.在Opera中,关闭浏览器中的最后一个选项卡不会关闭浏览器.相反,它会启动称为快速拨号的功能.这显然是Opera中的默认行为.我尝试禁用快速拨号,但它似乎没有阻止这种行为.

I'm attempting to add Opera to a node on our Selenium Grid but running into a problem closing the Opera browser. In Opera, closing the last tab in a browser does not close the browser. It instead launches something called Speed Dial. This is apparently the default behavior in Opera. I've tried to disable Speed Dial but it doesn't appear to prevent this behavior.

由于通过RemoteWebDriver运行的测试,我不能只在Opera节点上调用脚本来关闭窗口.

Due to the tests running via RemoteWebDriver, I can't just call a script on the Opera node to close the window.

我尝试了传统方法,该方法关闭选项卡,但是Opera会启动一个空白或快速拨号选项卡:

I've tried the traditional method, which closes the tab but then Opera launches either an empty or speed dial tab:

driver.close();
driver.quit();

我尝试执行操作并将密钥发送到html正文中:

I've tried performing an action and sending keys into the html body:

Actions action = new Actions(driver);
action.sendKeys(driver.findElement(By.xpath("//body")),Keys.CONTROL, Keys.SHIFT, "W");
action.build().perform();
driver.quit();

我还尝试过构建动作并将密钥发送到以太坊中:

I've also tried building an action and sending keys into the ether:

Actions action = new Actions(driver);
action.sendKeys(Keys.CONTROL, Keys.SHIFT, "W");
action.build().perform();
driver.quit();

有人找到适合此功能"的合适方法吗?

Has anyone found a suitable workaround for this 'feature'?

推荐答案

我发现此问题.

因此,感谢Kryshtopenko,解决方案是:

So thanks to the Kryshtopenko the solution is:

  • 对于Windows:

  • For windows:

Runtime.getRuntime().exec("taskkill /f /im opera.exe");

对于macOS:

Runtime.getRuntime().exec("pgrep 'Opera' | xargs kill");

这篇关于如何通过RemoteWebDriver完全关闭Opera浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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