javascript - 为 selenium webdriver 设置特定功能

标签 javascript selenium selenium-webdriver

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

在此示例中,我想更改 Firefox 浏览器的网络驱动程序的功能。我正在尝试用 Javascript 实现这一点。

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

我尝试了诸如调用 .withCapability() 之类的方法,但它没有按我的预期工作并导致程序崩溃。

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

有人知道如何做到这一点吗? 我在 API reference 中找不到任何内容或在互联网上。

最佳答案

这对我来说效果很好,可以在我的 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();

关于javascript - 为 selenium webdriver 设置特定功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42064878/

相关文章:

selenium - Play framework + Selenium webdriver + cucumber sticks on the first http request

Python Selenium 从 url 中抓取丢失的图像

selenium-webdriver - JRuby Watir phantomjs 异常未知错误(Windows 说 "The operation completed successfully.",但它没有。)

javascript - VueJS 数据未 react 安装

javascript - selenium 和 javascript,以 fancybox 为例子玩自动测试

selenium - 使用 Capybara 和 Selenium 将鼠标悬停在元素上

c# - selenium webdriver C# 多线程

javascript - 单击跨度后如何显示按钮?

javascript - Android和IOS移动设备 :calculate browser screen height excluding address bar and navigation bar height

javascript - node.js 需要 memcached 是什么?