1
  1. try to click an element
  2. check whether a certain string exists
  3. if false, throw an exit 1

This workaround works, but I wonder whether there is a selenium function that checks whether a click does not work?

2 Answers 2

1

You need to use Try-catch block to do it:

try {
    driver.findelement(by.id("")).click();
    fail();
} catch (Exception e) {
    // expected
}

// continue
0

I am using the below solution for this problem in my project. So whenever we clicks on an element something happens, like either we redirects to a new page or some elements appear on existing page etc etc. So on after every click we can add an assertion statement to check whether a new page opened successfully (we can verify this by verifying the page title or any elements on page), or the action which was supposed to happen on this page is actually happened or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.