In my t...">

Selenium: Why doesn't click () behave like it does in Firefox?

I have a link with id:

<a href="#" onclick="return false();" id="lol"> 

In my test:

 selenium.click("lol"); //when running the test, the click will just end up selecting the item, not firing off the frameworks javascript 

This does not register a click though! There is javascript that is part of a complex structure that will pop up a div popup. This works in firefox.

But this works as a fix:

 selenium.click("lol"); //when running the test, the click will just end up selecting the item, not firing off the frameworks javascript selenium.keyPress("lol", "\\13"); //press enter key, since the click ended up selecting it 

The fix works. But what is going on here? Selenium.click ()! = [Actual browser click event] seems to be. Can anyone help shed light on these inner works?

+4
source share
2 answers

Selenium sometimes doesn't simulate clicking on javascript hrefs for sure. Maybe this is the same problem. A quick fix is ​​to use a combination of selenium and mouse events. You can also use selenium.fireEvent("lol","click"); . Go back when you tried this.

+1
source

You can click the link in the browser before downloading javascript. See this other question . One solution would be to expect some element to appear on the page that is placed there javascript.

0
source

Source: https://habr.com/ru/post/1313665/


All Articles