Reputation: 158
I'm trying to retrieve HTML elements via jQuery and I keep getting null reference point exception, in every JavascriptExecutor statement I write. Is it me?
Here's my code:
List<Object> list= (List<Object>)(IJavaScriptExecutor)Browser).ExecuteScript("$('tbody').find('tr')");
list.Count.ShouldBeLessThan(rowsWithNewActivity);
Upvotes: 2
Views: 4242
Reputation: 27496
You're not returning anything from your JavaScript execution. Try this:
List<object> list = ((IJavaScriptExecutor)Browser).ExecuteScript("return $('tbody').find('tr');") as List<object>;
This should no longer return a null value, but rather should return the list you're looking for.
Upvotes: 7