How do I launch the browser using Selenium WebDriver?
Experience Level:
Junior
Tags:
Quality Assurance (QA)
Selenium
Answer
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 Quality Assurance (QA) job interview questions
-
What are the different types of waits available in WebDriver?
Quality Assurance (QA) Selenium Junior -
What are the different types of Drivers available in WebDriver?
Quality Assurance (QA) Selenium Junior -
Which is the latest Selenium tool?
Quality Assurance (QA) Selenium Junior -
What is the difference between / and // in XPath?
Quality Assurance (QA) XML Junior -
What is an XPath?
Quality Assurance (QA) Selenium XML Junior