Corporate Training
Request Demo
Click me
Let's Talk
Request Demo

Selenium Interview Questions and Answers For Experienced

by Anuradha, on Mar 27, 2018 12:13:01 PM

Selenium Interview Questions and Answers For Experienced

Q1. What are the annotations used in TestNG?

Ans:@Test@BeforeSuite,@AfterSuite,@BeforeTest,@AfterTest, @BeforeClass, @AfterClass, @BeforeMethod, @AfterMethod, @BeforeGroups, @AfterGroups

Q2. What is a hub in Selenium Grid?
Ans: A hub is a server or a central point that controls the test executions on different machines.

Q3. How do you read data from excel?

Ans: FileInputStream fis = new FileInputStream (“path of excel file”);

Workbook wb = WorkbookFactory.create (fis);

Sheet s = wb.getSheet (“sheetName”)

String value = s.getRow (rowNum).getCell (cellNum).getStringCellValue ();

Q4. What is a node in Selenium Grid?

Ans: Node is the machine which is attached to the hub. There can be multiple nodes in Selenium Grid.

Q5. What are Soft Assert and Hard Assert in Selenium?

Ans: Soft Assert: Soft Assert collects errors during @Test Soft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement

Hard Assert: Hard Assert throws an Assert Exception immediately when an assert statement fails and test suite continues with next @Test

Q6. What are the verification points available in Selenium?

Ans: In Selenium IDE, we use Selenese Verify and Assert Commands as Verification points

In Selenium WebDriver, there is no built-in features for verification points. It totally depends on our coding style. some of the Verification points are

To check for page title

To check for certain text

To check for certain element (text box, button, drop down, etc.)

Q7. What is POM (Page Object Model)? What are its advantages?

Ans: Page Object Model is a design pattern for creating an Object Repository for web UI elements. Each web page in the application is required to have it’s own corresponding page class. The page class is thus responsible for finding the Web Elements in that page and then perform operations on those Web Elements. The advantages of using POM are: Allows us to separate operations and flows in the UI from Verification – improves code readability Since the Object Repository is independent of Test Cases, multiple tests can use the same Object Repository Reusability of code

Q8. How to launch a browser using Selenium WebDriver?

Ans: WebDriver is an Interface. We create Object of a WebDriver Interface.

<2.53 – no geckodriver

3.x – geckodriver for FF

To launch Firefox Driver:
WebDriver driver = new FirefoxDriver();

To launch Chrome Driver:
WebDriver driver = new ChromeDriver();

To launch Internet Explorer Driver:
WebDriver driver = new InternetExplorerDriver();

Q9. Is the FirefoxDriver a Class or an Interface? 

Ans: FirefoxDriver is a Java class, and it implements the WebDriver interface.

Q10. What is the super interface of WebDriver?

Ans: SearchContext.

Q11. What is Page Factory?

Ans: Page Factory gives an optimized way to implement Page Object Model. When we say it is optimized, it refers to the fact that the memory utilization is very good and also the implementation is done in an object oriented manner. Page Factory is used to initialize the elements of the Page Object or instantiate the Page Objects itself. Annotations for elements can also be created (and recommended) as the describing properties may not always be descriptive enough to differentiate one object from the other. The concept of separating the Page Object Repository and Test Methods is followed here also. Instead of having to use ‘FindElements’, we use annotations like: @FindBy to find WebElement, and initElements method to initialize web elements from the Page Factory class. @FindBy can accept tagName, partialLinkText, name, linkText, id, css, className & xpath as attributes. Since the Object Repository is independent of Test Cases, multiple tests can use the same Object Repository Reusability of code

Q12. Explain the line of code Webdriver driver = new FirefoxDriver(); ?

Ans: ‘WebDriver‘ is an interface and we are creating an object reference of type WebDriver instantiating an object of FirefoxDriver class.

Q13. We do create a reference variable ‘driver’ of type WebDriver

Ans: WebDriver driver = new FirefoxDriver();

instead of creating

FirefoxDriver driver = new FirefoxDriver();

What is the purpose of doing this way?

f we create a reference variable driver of type WebDriver then we could use the same driver variable to work with any browser of our choice such as IEDriver, SafariDriver etc.,

//FirefoxDriver driver = new FirefoxDriver();

ChromeDriver driver = new ChromeDriver();


WebDriver driver = new FirefoxDriver();

Q14. What are the different exceptions you have faced in Selenium WebDriver?

Ans: WebDriverException







Q15. How to handle keyboard and mouse actions using Selenium?

Ans: We can handle special keyboard and mouse events by using Advanced User Interactions API. The Advanced User Interactions API contains the Actions and the Action Classes that are needed for executing these events. Most commonly used keyboard and mouse events provided by the Actions class are in the table below: Method Description clickAndHold() Clicks (without releasing) the current mouse location. dragAndDrop() Performs click-and-hold at the location of the source element, moves. source, target() Moves to the location of the target element, then releases the mouse

Q16. How To Login Into Any Site If It Is Showing Any Authentication Pop-Up For Username And Password?

Ans: To do this we pass username and password with the URL



Q17. What are the types of waits available in Selenium WebDriver?

Ans: In Selenium we could see three types of waits such as Implicit Waits, Explicit Waits and Fluent Waits.

Implicit Waits –

Explicit Waits –

Fluent Waits –


Thread.sleep() – static wait

Q18. What is Implicit Wait In Selenium WebDriver?

Ans: Implicit waits tell to the WebDriver to wait for a certain amount of time before it throws an exception. Once we set the time, WebDriver will wait for the element based on the time we set before it throws an exception. The default setting is 0 (zero). We need to set some wait time to make WebDriver to wait for the required time.

Q19. What is WebDriver Wait In Selenium WebDriver?

Ans: WebDriverWait is applied on a certain element with defined expected condition and time. This wait is only applied to the specified element. This wait can also throw an exception when an element is not found.

Q20. What are the different types of Drivers that WebDriver contains?

Ans: These are the different drivers available in WebDriver: FirefoxDriver InternetExplorerDriver ChromeDriver SafariDriver OperaDriver AndroidDriver IPhoneDriver HtmlUnitDriver

Q21. What is Fluent Wait In Selenium WebDriver?

Ans: FluentWait can define the maximum amount of time to wait for a specific condition and frequency with which to check the condition before throwing an “ElementNotVisibleException” exception.

Q22. How to input text in the text box using Selenium WebDriver?

Ans: By using sendKeys() method

WebDriver driver = new FirefoxDriver();



Q23. How to input text in the text box without calling the sendKeys()?

Ans: // To initialize js object

JavascriptExecutor JS = (JavascriptExecutor)driver;

// To enter username


Q24. How to clear the text in the text box using Selenium WebDriver?

Ans: By using clear() method

WebDriver driver = new FirefoxDriver();


driver.findElement(By.xpath("xpath_of_element1")).sendKeys("Software Testing Material Website");


Q25. How do you verify if the checkbox/radio is checked or not?

Ans: We can use isSelected () method.

Syntax – driver.findElement (By.xpath (“xpath of the checkbox/radio button”)).isSelected ();

If the return value of this method is true then it is checked else it is not.

Q26. How to get a text of a web element?

Ans: By using getText() method

Q27. How to get an attribute value using Selenium WebDriver?

Ans: By using getAttribute(value);

Q28. How to click on a hyperlink using Selenium WebDriver?

Ans: We use click() method in Selenium to click on the hyperlink

driver.findElement(By.linkText(“Software Testing Material Website”)).click();

Q29. How to submit a form using Selenium WebDriver?

Ans: We use “submit” method on element to submit a form


Alternatively, you can use click method on the element which does form submission

Q30. How to press ENTER key on text box In Selenium WebDriver?

Ans: To press ENTER key using Selenium WebDriver, We need to use Selenium Enum Keys with its constant ENTER.


Topics:Selenium Interview Questions and Answers For ExperInformation Technologies (IT)



Top Courses in Python

Top Courses in Python

We help you to choose the right Python career Path at myTectra. Here are the top courses in Python one can select. Learn More →

aathirai cut mango pickle