Selenium Node.js中的实验Chrome选项

jutyujz0  于 2023-02-27  发布在  Go
关注(0)|答案(2)|浏览(128)

我需要转换这些python行:

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(executable_path='<path-to-chrome>', options=options)

本期:Python selenium: DevTools listening on ws://127.0.0.1
我不知道如何在Node.js中添加实验选项,我找不到任何文档。

3yhwsihp

3yhwsihp1#

我也无法在Selenium Node.js中找到实验性的chrome选项。但是如果你想排除chrome开关,我想你可以这样做:

const {Builder} = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome'); 

const chromeOptions = new chrome.Options()
chromeOptions.excludeSwitches("enable-logging")

let driver = await new Builder().forBrowser('chrome').setChromeOptions(chromeOptions).build();
yqyhoc1h

yqyhoc1h2#

MOSI的解决方案对我很有效(顺便感谢)。我会投赞成票,但没有足够的代表。
我试图找出Node.js selenium脚本的输出生成以下语句的原因:“连接到系统的设备不起作用。(0x1F)”以及如何防止这些警告显示在我的输出中。

相关问题