2

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);

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.