1

I am running a getEval in Selenium with the following javascript:

document.getElementById("j_id0:j_id3:mainBlock:j_id40").children[0].children[0].children[0].children[0].children[0].children[0] .children[2].children[0].children[0].children[0] .children[0].children[1];

When I run the code in the console, it returns the correct result.

When I navigate to the page on which the element I need to locate exists and click the "find" button in Selenium, it finds and highlights the correct element. Hoever, when I actually run the line in Selenium - even when I navigate to the correct page and run ONLY that line - I get a message that says

[error]Threw an exception: document.getElementById(...)is null

How do I make this work correctly?

1 Answer 1

2

Just include this.browserbot.getUserWindow() before your actual JS stament started and try.

selenium.getEval("this.browserbot.getUserWindow().document.getElementById("j_id0:j_id3:mainBlock:j_id40").children[0].children[0].children[0].children[0].children[0].children[0] .children[2].children[0].children[0].children[0] .children[0].children[1]")
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.