Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling In Webdriver Using Chromeoptions

I am facing the error in chrome which is "You Are Using An Unsupported Command-Line Flag –Ignore-Certificate-Errors. Stability And Security Will Suffer." for my below selenium code.

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

I have searched the same error solution in below link.

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

Please explain how can i apply the answer mention in above link into my VBA code.

like image 270
sagar Avatar asked Oct 29 '22 05:10

sagar


1 Answers

I could not find documentation for SeleniumWrapper. So, I assumed that SeleniumWrapper.WebDriver.Start doesn't handle any `ChromeOptions' related arguments.

If the above assumption is true, one cannot apply the given solution in C#.

Instead, you may try the following: (I referenced 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

I added couple lines from my experience running Selenium in C#.

Please provide where SeleniumWrapper with its documentation to determine if one can/cannot set ChromeOptions for SeleniumWrapper.

like image 130
dey.shin Avatar answered Nov 15 '22 06:11

dey.shin