vba - 使用 Chromeoptions 在 Webdriver 中处理

标签 vba selenium selenium-webdriver selenium-chromedriver

我正面临 chrome 中的错误,即 “您正在使用不受支持的命令行标志 – 忽略证书错误。稳定性和安全性将受到影响。” 对于我下面的 Selenium 代码。

Public Sub key()
  Dim selenium As New SeleniumWrapper.WebDriver  
  selenium.Start "chrome", "https://google.com/"
selenium.stop
End Sub

我在下面的链接中搜索了相同的错误解决方案。

http://www.abodeqa.com/tag/how-to-remove-you-are-using-an-unsupported-command-line-flag-ignore-certificate-errors-stability-and-security-will-suffer/

请解释我如何将上面链接中提到的答案应用到我的 VBA 代码中。

最佳答案

我找不到 SeleniumWrapper 的文档。所以,我假设 SeleniumWrapper.WebDriver.Start不处理任何与“ChromeOptions”相关的参数。

如果上述假设成立,则不能申请 the given solution in C# .

相反,您可以尝试以下操作:(我引用了 this )

Imports OpenQA.Selenium
Imports OpenQA.Selenium.Chrome

...
...

Public Sub key()

  Dim service As OpenQA.Selenium.Chrome.ChromeDriverService = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService()

  Dim chromeOptions As New OpenQA.Selenium.Chrome.ChromeOptions()
  chromeOptions.AddExcludedArgument("ignore-certifcate-errors")
  chromeOptions.AddArgument("test-type")

  Dim driver As IWebDriver = New ChromeDriver(service, chromeOptions)
  driver.Navigate().GoToUrl("https://google.com/")

  driver.Quit()

End Sub

我根据在 C# 中运行 Selenium 的经验添加了几行代码。

请提供哪里SeleniumWrapper及其文档以确定是否可以/不能设置 ChromeOptionsSeleniumWrapper .

关于vba - 使用 Chromeoptions 在 Webdriver 中处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44923496/

相关文章:

c# - Chrome 驱动程序 : How to disable PDF plugin

excel - 未找到命名参数

testing - Selenium IDE - 出现意外确认!

VBA DoCmd.TransferText - 使用用户定义的文件路径将查询导出到 .csv

ruby-on-rails - Cucumber + webrat + selenium,如何忽略隐藏文本?

Ruby - Watir webdriver 在 browser.goto(url) 后超时,即使 URL 已成功加载

java - PhantomJSDriver.getCurrentUrl() 返回约 :blank

ruby-on-rails - ActiveRecord::RecordNotFound 用于在 'js: true' 功能规范中刚创建的记录

vba - 将 Excel 文件保存为不带引号的 .txt 格式

vba - 区分 MS Excel 中的数字和日期