This is because it will mess up the events and some clicking, specifically <a> and <button>,will fail.
(I have done a solid experiment on it. I have tested 4 elements, span, anchor, button, and input[button]. Only anchor and button have the problem)
----------------
OMG, I have solved it.
By focusing and send_keys "\n", the clicking problem is gone !!
Please be aware that the clicking problem only occurs with the anchor tag, and this approach does not work with other tags.
Therefore, please use the below code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
obj = browser.element(:id=>"test_span") | |
obj.focus | |
if ["a","button"].include?(obj.tag_name.downcase) | |
obj.send_keys "\n" | |
else | |
obj.click | |
end |
YESSSSS!
--------------------
I have found a problem with <button> that contains a span inside. But I could not repeat the problem. So, I'll just make a note right here for future reference.