jeudi 27 juillet 2017

Selenium IDE - TypeError: document.getElementById(..) is null

The situation is, that I want to use "runScript" in order to send a xmlhttprequest in the beginning when the website gets opened, find an element in the responseText, see if a specific textcontent is present and if so, I want to click on that element.

I am not allowed to show you the source of the website, but I hope your still able to (maybe) find the mistake.

My script:

javascript{
var req = new XMLHttpRequest();
req.addEventListener("load", function(event) {
 if(req.status >= 200 && req.status < 300)
 {
   var parser = new DOMParser();
   var xmlDoc = parser.parseFromString(req.responseText, "text/html");
   if(document.getElementById("application_widgets__0_selectedUserLanguage_label").childNodes[0].textContent=="English")
   {
     document.getElementById("application_widgets__0_selectedUserLanguage_label").parentNode.click()
   }
 }
 });
req.open("GET", "..............................");
req.send();
}

I've already tested it in the console of firebug before putting it into the Selenium IDE and it works perfectly. But I always get the same exception when running it in Selenium IDE:

enter image description here

My question is: why does it work in firebug but not in selenium IDE and what did I do wrong?

  • no there's no iframe

Thanks for the answers in advance! :)




Aucun commentaire:

Enregistrer un commentaire