Tuesday 9 February 2016

Q)Selenium : Find the output for the following program

Q)Selenium : Find the output for the following program:
============================================
package blog;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class DoubleClickDemo {

WebDriver driver;
Actions actions;
String expectedTitle = "jQuery UI";

@BeforeSuite
public void openBrowser() {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);

}

@AfterSuite
public void closeBrowser() {
if (driver!=null) {
driver.quit();
}

}
@Test
public void testScript() {
driver.get("https://www.jqueryui.com");

String actualTitle = driver.getTitle();
if (actualTitle.equalsIgnoreCase(expectedTitle))
{

WebElement element = driver.findElement(By.linkText("Autocomplete"));
Actions actions = new Actions(driver);
actions.doubleClick(element).click().build().perform();
}

}

}

OUTPUT:
--------------
1.   Compile Time Error
2.   Null PointerException
3.   NoSuchElementException
4.   None of the above


ANSWER :  Null PointerException



No comments:

Post a Comment