Last active
April 24, 2020 13:59
-
-
Save jimevans/eea715368ea3ae664099ab5ce409d686 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| HttpCommandExecutor commandExecutor = new HttpCommandExecutor(new Uri("http://hub-cloud.browserstack.com/wd/hub/"), TimeSpan.FromSeconds(60)); | |
| commandExecutor.Proxy = new WebProxy("http://address:port", false); | |
| ChromeOptions options = new ChromeOptions(); | |
| options.AddAdditionalCapability("browser", "Chrome"); | |
| options.AddAdditionalCapability("browser_version", "80.0"); | |
| options.AddAdditionalCapability("os", "Windows"); | |
| options.AddAdditionalCapability("os_version", "10"); | |
| options.AddAdditionalCapability("resolution", "1024x768"); | |
| options.AddAdditionalCapability("browserstack.user", "user"); | |
| options.AddAdditionalCapability("browserstack.key", "key"); | |
| options.AddAdditionalCapability("name", "Bstack-[C_sharp] Sample Test"); | |
| IWebDriver driver = new RemoteWebDriver(commandExecutor, options.ToCapabilities()); | |
| driver.Navigate().GoToUrl("http://www.google.com"); | |
| Console.WriteLine(driver.Title); | |
| IWebElement query = driver.FindElement(By.Name("q")); | |
| query.SendKeys("Browserstack"); | |
| query.Submit(); | |
| Console.WriteLine(driver.Title); | |
| driver.Quit(); |
Author
Good catch, @maddysk3. I was writing this from memory, without the aid of an IDE, and missed the closing parenthesis.
As for the AddAdditionalCapability, this particular gist was provided as an answer to a specific question from a Selenium user. In their code, they did not use the three-argument overload of AddAdditionalCapability; they used the two-argument overload, and I was deliberately preserving their choice of which method to call.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HttpCommandExecutor commandExecutor = new HttpCommandExecutor(new Uri("http://hub-cloud.browserstack.com/wd/hub/", TimeSpan.FromSeconds(60));
In the above line ")" is missing after the hub URL
Also options.AddAdditionalCapability("", "","true"); acceps three arguments and last argument should be true.