Null Pointer Exception | Selenium Forum
M
Posted on 21/08/2015
hai, i am getting null pointer exception in second test menthod checkHomePageLeftBoxLinks(). i have define all the login details and navigate url in doDefaultLogin() function and i define this doDefaultLogin() function in TestBase.java. if i put checkHomePageLeftBoxLinks() code in login() then its working but if i used it in checkHomePageLeftBoxLinks() then its throwing null pointer exception.

i have understood that driver getting null but how i define driver here with my url.
Please suggest


@Test
public void login(){
doDefaultLogin("Mozilla");
APPLICATION_LOG.debug("Login Successfull");
//WebElement leftBox = driver.findElement(By.xpath("//*[@id='divList']"));
//List<WebElement> productLink = leftBox.findElements(By.xpath("//div[@class='listRecent roundCornersSmallLeft']"));
//System.out.println("Total Link -"+productLink.size());
}

@Test
public void checkHomePageLeftBoxLinks() throws InterruptedException{

WebElement leftBox = driver.findElement(By.xpath("//*[@id='divList']"));
List<WebElement> productLink = leftBox.findElements(By.xpath("//div[@class='listRecent roundCornersSmallLeft']"));
System.out.println("Total Link -"+productLink.size());

}

M
Replied on 21/08/2015

Please post complete error here


M
Replied on 21/08/2015

see attached image and reply please.

ha ha ha...................when attaching file receiving error <The file is too big, maximum allowed size is 4 KiB.>.

now you told what happen in only 4KB.
gmail is better rather than it.

how i send you told, whay you did not test it properly.


M
Replied on 21/08/2015

This is the messge................

java.lang.NullPointerException


M
Replied on 21/08/2015

<The file is too big, maximum allowed size is 4 KiB.>

hi bhupesh what was the extension of file you were trying to upload?

we can fix this don't worry.


M
Replied on 22/08/2015

Bhupesh.. paste the complete stack trace here


M
Replied on 22/08/2015

If you can paste complete stack trace here then we can help....


M
Replied on 23/08/2015

i am not getting stacktrace, when i am running as a testng suite then i am getting only result for java null pointer exception.

Responsive image

M
Replied on 23/08/2015

i done it thanks................