Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Selenium Interview Questions and Answers

Ques 36. What are the different methods to refresh a web page in WebDriver?

There are multiple ways of refreshing a page in Webdriver.

1. Using driver.navigate command -

 

driver.navigate().refresh();  

 

2. Using driver.getCurrentUrl() with driver.get() command -

 

driver.get(driver.getCurrentUrl());  

 

3. Using driver.getCurrentUrl() with driver.navigate() command -

 

driver.navigate().to(driver.getCurrentUrl());  

 

4. Pressing an F5 key on any textbox using the sendKeys command -

 

driver.findElement(By textboxLocator).sendKeys(Keys.F5);  

 

5. Passing ascii value of the F5 key, i.e., "\uE035" using the sendKeys command -

 

driver.findElement(By textboxLocator).sendKeys("\uE035");  

Is it helpful? Add Comment View Comments
 

Ques 37. Write a code snippet to navigate back and forward in browser history?

Navigate back in browser history:

 

driver.navigate().back();  

 

Navigate forward in browser history:

driver.navigate().forward();  

Is it helpful? Add Comment View Comments
 

Ques 38. How to invoke an application in WebDriver?

driver.get("url"); or  

driver.navigate().to("url");  

Is it helpful? Add Comment View Comments
 

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

Page Object Model is a design pattern for creating an Object directory for web UI elements. Each web page is required to have its page class. The page class is responsible for finding the WebElements in web pages and then perform operations on WebElements.

The benefits of using POM are as follows:

  • It facilitates with separate operations and flows in the UI from Verification - improves code readability
  • Multiple tests can use the same Object Repository because the Object Repository is independent of Test Cases.
  • Reusability of code

Is it helpful? Add Comment View Comments
 

Ques 40. How can you find if an element is displayed on the screen?

WebDriver allows user to check the visibility of the web elements. These web elements can be buttons, radio buttons, drop, checkboxes, boxes, labels etc. which are used with the following methods.

  • isDisplayed()
  • isSelected()
  • isEnabled()

isDisplayed():  

boolean buttonPresence = driver.findElement(By.id("gbqfba")).isDisplayed();  

isSelected():  

boolean buttonSelected = driver.findElement(By.id("gbqfba")).isSelected();  

isEnabled():  

boolean searchIconEnabled = driver.findElement(By.id("gbqfb")).isEnabled();  

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook