seleniumonlinetutor

Selenium Interview : How will you capture screenshot in Selenium webDriver?

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 void testcase1() { // Open Firefox WebDriver driver=new FirefoxDriver(); // Maximize the window driver.manage().window().maximize(); // Open the url driver.get(“http://www.google.com”); // Take screenshot and store as […]

Read More »

Selenium Interview : What is the difference between findElement and findElements?

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 is used to find the one web element. It return only one WebElement type. findElements()– it is used to find more than one web element. […]

Read More »

Selenium Interview : How will you perform drag and drop using WebDriver?

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(“ —–”)); //source element which you want to drag WebElement target = driver.findElement(By.xpath(“ —–”)); //target where you want to drop act.dragAndDrop(source,target).perform();

Read More »

Selenium Interview: How to double click in Selenium WebDriver?

How would you double click in Selenium ? It’s very simple. You just need few lines of code. You will need to use Actions class . Here is the sample code: WebDriver driver=new FirefoxDriver(); driver.get(“https://www.facebook.com/”); //on below element , we will double click WebElement we=driver.findElement(By.id(“day”)); // Create object of Actions class and build action Action […]

Read More »