Selenium Interview Questions

Displaying 1 - 10 of 153

Why is Selenium a choice tool for automation testing?

  • It is open source
  • It supports distributed testing
  • It has regular repository developments
  • It has a large user base and support community
  • It has wide platform compatibility – Windows, Mac OS, and Linux, etc. 
  • It has cross-browser compatibility – Internet Explorer, Chrome, Firefox, Safari, etc.
  • It supports multiple programming languages – Java, C#, Ruby, Perl, Python, etc.

What are the multiple ways to click on Submit button in Selenium?

Here are the list of techniques:

.click() method: You can use .click() method to click on any button of software web application. Means element's type = "button" or type = "submit", .click() method will works for both.

WebElement myButton = driver.findElement(By.cssSelector("locator"));;

.submit() method: If you will look at firebug view for any form's submit button then always It's type will be "submit". In this case, .submit() method Is very good alternative of .click() method.

WebElement myButton = driver.findElement(By.cssSelector("locator"));


WebElement myButton = driver.findElement(By.cssSelector("locator"));

Action Class:

WebElement myButton = driver.findElement(By.cssSelector(locator));
Actions builder = new Actions(driver);


WebElement myButton = driver.findElement(By.cssSelector(locator));
JavascriptExecutor js = (JavascriptExecutor)driver;		
js.executeScript("arguments[0].click();", myButton);

What are the challenges with PageFactory?

Below are the challenges with PageFactory:

  1. No of Pages: If there is an application with hundreds or thousands of web pages then the time and the effort in the development of automation framework will be high.
  2. Maintenance Overhead: The cost increases when maintenance overhead increases which are due to the maintenance of large class as they break the OO design principle.
  3. Programming Best Practices: The development of POM framework for multiple pages is equal to developers work thus testers should be highly knowledgeable in programming best practices.
  4. Not Generic Model: Page object model is not a generic model and its specific to the applications.

The best approach to overcome the above challenges is by refactoring the POM concept to Screenplay Pattern.

If Timeout of Explicit wait is 30 Seconds and Timeout for Implicit Wait is 60 seconds

Consider element is not found then for how much time script will wait before the exception is thrown. 


Case 1: When Implicit Wait > Explicit Wait. For Example Implicit Wait is 60 seconds and Explicit Wait is 30 Seconds.

Then, Script will wait for 60 seconds.

Case 2: When Explicit Wait > Implicit Wait. For Example Implicit Wait is 20 seconds and Explicit Wait is 40 Seconds.

Then, Script will wait for 40 seconds.

How do you click on a menu item in a drop down menu in Selenium?

If that menu has been created by using select tag then we can use the methods selectByValue() or selectByIndex() or selectByVisibleText(). These are the methods of the Select class.

If the menu has not been created by using the select tag then we can simply find the xpath of that element and click on that to select.

How do perform drag and drop using Selenium WebDriver?

Use Action Class:

Actions act = new Actions(driver);
WebElement source = driver.findElement(By.xpath("")); //source element which you want to drag
WebElement target = driver.findElement(By.xpath("")); //target where you want to drop
act.dragAndDrop(source, target).perform();

How do you launch IE/Firefox/Chrome browser using Selenium?

Check below code:

WebDriver driver;

    System.setProperty("", Constants.CHROME_EXE);
    driver = new ChromeDriver();
else if(browser.equals("Firefox")) 
    System.setProperty("webdriver.gecko.driver", Constants.FIREFOX_EXE);
    driver = new FirefoxDriver();
else if(browser.equals("IE"))
    driver = new InternetExplorerDriver();