- try to click an element
- check whether a certain string exists
- 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?
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It only takes a minute to sign up.
Sign up to join this communityYou need to use Try-catch block to do it:
try {
driver.findelement(by.id("")).click();
fail();
} catch (Exception e) {
// expected
}
// continue
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.