Skip to main content

Posts

Showing posts from August, 2017

Selenium with Java Interview Questions and Answers

What exception will be thrown when we use "findElement" method? NoSuchElementException will be thrown when the locator is not found in the DOM and no longer available. How will you handle popups windows in Selenium? We can handle popups in Selenium is simple. It provides various methods from WebDriver interface. They are, 1. getWindowHandle() 2. getWindowHandles() getWindowHandle() - deals with current window getWindowHandles() - it manages with multiple windows and returns set of instances Let me show an example to understand this better, import java.util.Iterator; import java.util.Set; import org.openqa.selenium.firefox.*; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import org.testng.annotations.AfterTest; public class PopupDemo {  private WebDriver driver;  @BeforeTest  public void setUp()  { System.setProperty("webdriver.firefox.bi