Buttons

You have done a double click

You have done a right click

You have done a dynamic click



Basic button

The button below displays an alert when clicked.

Stale button

Selenium clicks fail when an element is not attached to the current page. Re-find the element if the previously found element has been detached.

Disabled button

Disabled buttons don’t fire click events. A wait condition can be used if the button eventually transitions to enabled.

Hidden button

Invisible elements cannot be clicked. Wait until elements become visible.

Covered button

Overlapping elements intercept clicks from overlapped ones. Wait for the element to be uncovered.

Overlapping element

Moving button

Firefox’s geckodriver reliably clicks moving elements. ChromeDriver requires extra work.

Example:

Sending an ‘Enter’ key directly to an element simulates a click.  (Of course, clicking and pressing ‘Enter’ aren’t exactly the same but may be good enough).

Resizing button

Because Selenium attempts to click the center of elements, an element that changes size adjusts the click location and creates similar pitfalls in ChromeDriver to that of a moving element. Wait for the size to stabilize.

Example:

The same ‘Enter’ trick for moving elements can be used with elements that change size.

Refreshing button

Elements that are periodically refreshed can separate Selenium’s find and/or click events. Executing Javascript to perform the find and click prevents separation.

I love open-source technologies and am very passionate about software development. I like to share my knowledge with others, especially on technology that's why I have given all the examples as simple as possible to understand for beginners. All the code posted on my blog is developed, compiled, and tested in my development environment. If you find any mistakes or bugs, Please drop an email to softwaretestingo.com@gmail.com, or You can join me on Linkedin.

Customer service

(123)45-67-890

Claim & damage

121 444 2200

help@softwaretestingo.com