Interview Questions

SELENIUM REAL TIME INTERVIEW QUESTIONS - How to run tests in multiple browser parallel? Is there any other option other than selenium grid?

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

SELENIUM REAL TIME INTERVIEW QUESTIONS - How to run tests in multiple browser parallel? Is there any other option other than selenium grid?

You create a class with a method something like this:
public class LaunchBrowser {
WebDriver driver=null;
// Pass parameter browser from test.xml
@Parameters(“browser”)
public void initiateBrowser(String browser){
// compare browser to fire fox and then open firefox driver
if(browser.equals(“Firefox”))
{

driver = new FirefoxDriver();
}
else
{
\ set path to the IE driver correctly here
System.setProperty("webdriver.ie.driver", "\iexploredriver.exe");
driver =new InternetExplorerDriver();
}
}
Now create YourClassName class and call extend the above class something like this
@Test
public class YourClassName extends LaunchBrowser{

public void gotoGoogle(){

driver.get(“http://www.google.com");
}
}

(Continued on next question...)

Other Interview Questions