Selenium click operation doesn’t work sometimes


#1

Summary:

  • a click operation isn’t processed or a click operation raise other click opration to be processed when operated by selenium code.
  • All the operation works correctly when operated by myself(just click by my finger).

Do you know what’s wrong with it?

Environment:

  • Macbook Pro /OS X Yosemite(10.10.4)
  • Electron
    • v0.33.1
    • v0.36.1
  • ChromeDriver
    • chromedriver-v2.15-darwin-x64
    • chromedriver_mac32_2_20
  • jQuery 1.11.3

Description:

1 At first, I packaged Electron app from the HTML code below.

<html>
<head>
...
<script>
window.jQuery = window.$ = require("jquery");

$(function() {
  $("#link1").click(function() {
    $("#status1").text("OK");
  });

  $("#link2").click(function() {
    $("#status2").text("OK");
  });

  $("#link3").click(function() {
    $("#status3").text("OK");
  });
});
</script>
</head>

<body>
<span id="status1"></span><a href="#1" id="link1" class="link">link1</a><br>
<span id="status2"></span><a href="#2" id="link2" class="link">link2</a><br>
<span id="status3"></span><a href="#3" id="link3" class="link">link3</a><br>
</body>
</html>

2 Launch the app and click each link by my finger from above, then “OK” is displayed. That seems to work correctly.

3 I wrote the selenium ruby code below.

...
link1 = driver.find_element(:id, 'link1')
link1.click

sleep(5)

link2 = driver.find_element(:id, 'link2')
link2.click

sleep(5)

link3 = driver.find_element(:id, 'link3')
link3.click
...

(Below is the point of the issue)

4 Execute the code, then “OK”, “OK” are displayed following link1.click, link2.click. However, 3rd “OK” is not displayed following link3.click.

Anyone knows what happened?

P.S.
If I add link4 and execute the selenium code, link3.click has started a click event of link4 on the application side.

Best regards,