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
Using Selenium, when do we use findElement(...) and findElements(...)?
Quality Assurance (QA)Selenium JuniorHow to type text into a textbox using Selenium?
Quality Assurance (QA)Selenium JuniorWhich is the latest Selenium tool?
Quality Assurance (QA)Selenium JuniorWhat are the different types of locators in Selenium?
Quality Assurance (QA)Selenium JuniorWhen should I use Selenium IDE?
Quality Assurance (QA)Selenium Junior