How will you take screenshot in Selenium webDriver? Answer: The screenshot can be taken by using getScreenshotAs() method. The sample code is as follows: public class myTestSuite { @Test public…
Tag: test automation interview questions
What is the difference between findElement and findElements? Answer: Both methods are abstract method of WebDriver interface and used to find the WebElement in a web page. findElement() – it…
What is the difference between driver.close() and driver.quit()? Answer : driver.close() – it will close the browser where the control is. driver.quit() – it will close all the browsers opened…
How do you handle alert pop-up in Selenium ? Answer: In Selenium webDriver, to handle alert pop-ups, we first need to switch control to alert pop-ups then click on ok…
How do you simulate browser back and forward in Selenium? Answer: The sample code is as follows: WebDriver driver=new ChromeDriver(); driver.navigate().back(); driver.navigate().forward();
How will you perform drag and drop using WebDriver? Answer: We can use Actions class. The sample code is as follows: Actions act = new Actions(driver); WebElement source = driver.findElement(By.xpath(“…
What are different types of locators in Selenium ? Ans- The different locators are : By.id(), By.name(), By.tagName(), By.className(), By.linkText(), By.partialLinkText(), By.xpath, By.cssSelector().
What are the annotations used in TestNG ? Ans: @Test, @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeClass, @AfterClass, @BeforeMethod, @AfterMethod.