0
string str = "var temp = window.document.getElementById('ctl00_PageContentPlaceHolder_Manager');temp.style.display = 'inline';";
str += "temp.add(new Option('111', '222'));";
str += "temp.nextSibling.childNodes[1].innerHTML = '<I></I><SPAN></SPAN>Edit Manager Contact';";
//selenium.RunScript(str);
selenium.GetEval(str);

Track the error log to see, seems "temp.add(new Option('111', '222'));"; statement is not work under getEval command. the error show:

"Access to property denied"

Beside context different from these two commands. Why?

1 Answer 1

2

Runscript runs the script in the same scope, but GetEval takes str and tries to run it in a different scope. If the issue is with temp.add statement, I guess it is because definition of Option is not coming in the scope when executed by GetEval .

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

2 Comments

i try to put the whole str into same scope.But the error is still existing. str=" window.document.getElementById('ctl00_PageContentPlaceHolder_Manager');temp.style.display = 'inline';temp.add(new Option('111', '222'));temp.nextSibling.childNodes[1].innerHTML = '<I></I><SPAN></SPAN>Edit Manager Contact';";
Try this- string str = "var temp = new Option('111', '222');" selenium.GetEval(str); and see whether it is working.

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.