如何在Mac OSx的Ruby中使用Selenium在后台运行chrome驱动程序? [英] How to run chrome driver in background using selenium with Ruby for Mac OSx?

查看:112
本文介绍了如何在Mac OSx的Ruby中使用Selenium在后台运行chrome驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时,浏览器窗口出现在前台,而我无意中单击了它,这使测试有时无法通过.因此,我只想知道,有什么方法可以将chrome驱动程序窗口保留在后台.

Sometimes, the browser window comes to the foreground and I'm clicking it accidentally which makes the test fails on some occasions. So, I just want to know, is there any way that I can keep the chrome driver window in the background.

详细信息: < ChromeDriver版本:2.28.455517> < Chrome版本:58.0.3029.96>

Details: < ChromeDriver version: 2.28.455517 > < Chrome version: 58.0.3029.96 >

推荐答案

您可以尝试使用适用于Chrome的无头开关.

You can try using headless switch available for Chrome.

这将在无头模式下运行自动化,并且您不会受到干扰.

This will run the automation in the headless mode and you will not be disturbed.

options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')

然后,启动Chrome.

Afterward, initiate Chrome.

这篇关于如何在Mac OSx的Ruby中使用Selenium在后台运行chrome驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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