Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Status-Untriaged
New issue 7055 by
harishks...@gmail.com: RemoteWebDriver throwing NPE at
@FindBy annotations
http://code.google.com/p/selenium/issues/detail?id=7055
1. I am Using RemoteWebDriver(Grid in configuration) + TestNG with Page
Object Factory Patterns,I am using @FindBy annotations to find the
WebElement.When I am running test cases,Remote WebDriver is throwing NPE
for each call of @FindBy.
2.These test cases working fine with Safari Driver and not throwing
exception.
3.These test cases working fine when using RemoteWebDriver and "By" methods
to locate the elements.
4.Hub and Nodes are running on local machine .
Below is the code :
SetUP Class :
public class PageSetup
{
public WebDriver driver; // = new SafariDriver();
/* This method will run before every class which contains tests */
@BeforeClass
public CreateOneTimeTaskPage launchSite()
{
try
{
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setBrowserName("safari");
desiredCapabilities.setVersion("6.0.5");
desiredCapabilities.setPlatform(org.openqa.selenium.Platform.MAC);
driver = new RemoteWebDriver(new
URL("
http://localhost:4444/wd/hub"),desiredCapabilities) ;
driver.get(props.getProperty("URL"));
}
catch(Exception e)
{
e.printStackTrace();
}
return new CreateOneTimeTaskPage(driver);
}
@AfterClass
public void tearDown()
{
driver.quit();
}
Page Object Class:
public class TaskPageObjects {
private WebDriver driver;
public TaskPageObjects(WebDriver driver) {
this.driver = driver;
}
@FindBy(id = "pdata")
private WebElement pDataElement; //Throwing NPE here
public TaskPageObjects checkBoxData(WebDriver driver)
{
try
{
pDataElement.click(); // Throwing NPE here
//driver.findElement(pDataElementLocator).click(); WORKING FINE
driver.manage().timeouts().implicitlyWait(3,TimeUnit.SECONDS);
}
catch(Exception e)
{
e.printStackTrace();
}
return this;
}
TEST CLASS :
public class TasksTests extends PageSetup{
TasksPage taskPage = PageFactory.initElements(driver,TasksPage.class);
@Test(enabled=true, groups="Tasks")
public void test_DescriptionOfTask()
{
taskPage.checkBoxData(driver); //Throwing NPE here
}
}
Exception :
java.lang.NullPointerException
at
org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:59)
at
org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:34)
at com.sun.proxy.$Proxy8.sendKeys(Unknown Source)
at com.apple.mqm.pfa.PO.TaskPage.selectProduct(TaskPage.java:833)
at
com.apple.mqm.pfa.Tests.TasksTests.test_DuplicateFunctionality(TasksTests.java:95)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:335)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Selenium version:selenium-server-standalone-2.40.0 (running on hub)
OS:Mac(10.8.4)
Browser:Safari
Browser version:6.0.5
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings