繁体   English   中英

设置Selenium WebDriver的特定功能

[英]Setting specific capabilities for selenium webdriver

我正在尝试为Selenium Webdriver设置一些特定功能

在此示例中,我想更改Firefox浏览器capability of the webdriver 我正在使用Javascript尝试此操作。

this.driver = new selenium.Builder().forBrowser('firefox').build();

我尝试了诸如调用.withCapabilities()类的事情,但是它没有按我预期的那样工作并使程序崩溃。

具体来说,我想将“ acceptSslCerts ”功能设置为true,因为默认情况下它为false。

有人对此有想法吗? 我无法在API参考或互联网上找到任何内容。

对于Firefox,可以通过FirefoxProfile接受SSL证书。

例如FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setAcceptUntrustedCertificates(真)

对于googlechrome,可以通过DesiredCapability设置浏览器属性。

在我的chrome浏览器中设置CORS对我来说效果很好。

const { Builder, By, Key, until } = require('selenium-webdriver');

const capabilities = {
    'chromeOptions': {
        'args': ['--disable-web-security', '--user-date-dir']
    }
}
let driver = new Builder().withCapabilities(capabilities).forBrowser('chrome').build();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM