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);
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);
Share
Improve this question
edited Jun 26, 2015 at 9:16
Ripon Al Wasim
37.9k42 gold badges159 silver badges178 bronze badges
asked Sep 4, 2012 at 5:34
ZSnakeZSnake
1581 gold badge3 silver badges12 bronze badges
1 Answer
Reset to default 7You'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.