eclipse - I am getting error "java.lang.NullPointerException" -
i using selenium webdriver testing web application. using marioette driver same havin firefox 48.0 since yusing same web page gets open not able put values in text box gives error " java.lang.nullpointerexception" have written code
@beforetest public void setup() throws exception { system.setproperty("webdriver.gecko.driver", "d:\\ashwini\\geckodriver.exe"); driver= new marionettedriver(); driver.manage().timeouts().implicitlywait(30, timeunit.seconds); } @test public void testaddaccount() throws exception { driver.get("http://qa.luna.wexeurope.com/cpcardweb/login.htm?programme=cpycgb"); driver.findelement(by.id("username")).clear(); driver.findelement(by.id("username")).sendkeys("cp_admin"); } @aftertest public void teardown() { driver.quit(); }
output is:
1472448949884 marionette info sendasync 3744f8a9-772e-42fe-8c85-6f9964888fb1 failed: testaddaccount java.lang.nullpointerexception @ add_account.testaddaccount(add_account.java:36) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source)
i have checked same gives null values in sendkeys. instead of by.id have used other options name, xpath, css selector same gives error only. value still not inserted in text box
line no 36 driver.findelement(by.id("username")).clear(); driver.findelement(by.id("username")).sendkeys("cp_admin");
i have debug said, yes passes null value element that's why throws null pointer exception. please let me know solve this. have tried pass values using id, name, xpath, css selecter. same error displayed. u please me?
nullpointerexception
means driver not initialized , hence has null value when tries find element. not related xpath/id etc.
please check line number 36 of add_account class know there error. if put whole code of class into.
Comments
Post a Comment