Issue
I'm using IE driver with java. I've done this fine in c# but trying java and hitting a snag. I instantiate the driver with a singleton pattern at the class level and then begin a junit test with the @Test. I separated the finding of the element out from the action and the finding of the element works great identifying the element with id=69 and the hexidecimal code the browser auto-assigns it. So far so good.
Then I take that variable for the WebElement and pass it into the action.click(element);
At this point an InvocationTargetException
is thrown with a null. Researching I have found where the driver null is causing an issue, but like I said driver is not null and has an element variable that populates accurately.
I'm wondering if there is something wrong with the selenium reference or something behind the scenes that may be throwing null when trying to utilize the library. Any ideas where I might look to get this to work? This is technically a java.lang.reflect exception and not a selenium specific exception, which if it was a null variable I would expect it to throw a selenium exception.
Any pointers or thoughts would be appreciated.
Solution
I found the answer. The actions class was unbound to the driver. So I could use the driver all I wanted, but the actions initiation couldn't find the browser to execute the actions on. I had a sub-class named Action that I was working with which confused me with the "Actions" class that was selenium.
Oops, but if anyone runs into that InvocationTargetException
with a null value while trying to utilize selenium, be sure that each selenium class is properly instantiated and associated with the active driver instance.
Answered By - mutt
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.