How do I launch the browser using Selenium WebDriver?

Experience Level: Junior
Tags: Quality Assurance (QA)Selenium

Answer

  • Create a new WebDriver instance for a specific browser.
  • Call Navigate() to retrieve a navigation object.
  • Then call GoToUrl(...) method and pass the URL that you want the browser to navigate to as a parameter.

 Long story short, do something like this:

using (var driver = new FirefoxDriver())
{
  var url = "https://www.bettercoder.com";
  driver.Navigate().GoToUrl(url);
}

If you are wondering what the "using" keyword is good for, it's a C# way to release the driver from memory once it's not needed anymore.

 
 
 
 
Related Selenium job interview questions

Comments

No Comments Yet.
Be the first to tell us what you think.
Selenium training
Selenium training

Are you learning Selenium ? Try our test we designed to help you progress faster.

Test yourself