在运行硒时如何将参数传递给谷歌浏览器? [英] How do I pass arguments to google chrome when running selenium?

查看:150
本文介绍了在运行硒时如何将参数传递给谷歌浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在运行硒时能够将参数传递给google chrome。我怎样才能做到这一点?当我运行selenium时,我使用Java命令Java -jar selenium.jar



如何传递参数,如no-sandbox,ignore-gpu-blacklist,enable-webgl到谷歌浏览器可执行文件。谢谢

我正在使用nightwatch

解决方案

在您启动驱动程序的方法中。例如

  public static WebDriver chromeBrowser()throws Throwable {
System.setProperty(webdriver.chrome.driver, C:\\chromedriver-location\\chromedriver.exe);
ChromeOptions选项=新ChromeOptions();
options.addArguments( - no-sandbox);
WebDriver浏览器=新的ChromeDriver(选项);
browser.manage()。timeouts()。implicitlyWait(30,TimeUnit.SECONDS);
返回浏览器;
}


I want to be able to pass arguments to google chrome when running selenium. How can I do that? When I run selenium I use the Java command Java -jar selenium.jar

How can I pass arguments such as no-sandbox, ignore-gpu-blacklist, enable-webgl to google chrome executable. Thanks

I'm using nightwatch

解决方案

You can send them in your method for launching the driver. e.g.

public static WebDriver chromeBrowser() throws Throwable {
        System.setProperty("webdriver.chrome.driver", "C:\\chromedriver-location\\chromedriver.exe");
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--no-sandbox");
        WebDriver browser = new ChromeDriver(options);
        browser.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        return browser;
    }

这篇关于在运行硒时如何将参数传递给谷歌浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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