0

I'm using Eclipse/Java and interfacing with the Selenium chrome webdriver.

The code I'm executing is

Sting sValue = item.getAttribute("innerHTML");

If I am stepping over this code it works fine. Otherwise, if I just run the code. It throws a NUllPointerException.

What gives? Any ideas? Thanks!

Daniel
  • 1

2 Answers2

0

It's possible the page doesn't have enough time to load when you run straight through, but when you step with the debugger it's just enough extra time for the page to finish loading and avoid the NullPointerException. Try adding a wait, as described in the accepted answer for this question: Getting Selenium to pause for X seconds.

Community
  • 1
  • 1
rswords
  • 31
  • 2
0

This is not a real answer, it's just a total hack! I have to get some things done so I'll investigate predicates and WebDriverWaits later. I was creating a list of webelements:

List wElements = getElements() Then I was trying to get the innerHTML from each webelement in the list. It works fine in debug mode, but when I execute the code it fails to gather the information IN SOME OF THE ELEMENTS in the collection. So what I did was retrieve the same list a second time. List wElementsB = getElements()

Then I retrieved the innerHTML out of the wELementsB. Works fine. I tried sleeping and telling the webdriver to wait. but those failed as well. Thanks Guys!

Daniel
  • 1