Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make actions optional in Selenium IDE?

This is a bit of a newbie question, but... is there a way to make actions optional in Selenium IDE? I'll provide a use case.

In the app I'm testing, users see a "hey, you're agreeing to the ToS by logging on"-type modal window at the beginning of each session. They have to click OK to continue, and they don't see the window again until the next session.

Based on what I've seen so far, I need to have one test suite for the first test each day, and a second test suite for all the others. The second suite is exactly the same except that it doesn't have the "click okay to dismiss the initial modal window" step. Alternatively, I could just remember that my first run of the test each day will fail, and that I have to run the test again.

Both of those "solutions" seem unnecessarily awkward. Can I just make the click command optional?

like image 694
Pops Avatar asked Jan 21 '23 12:01

Pops


1 Answers

Create a javascript file called user-extensions.js with the below code. Then go into the Selenium IDE Options dialog and select your user-extensions.js file, restart Selenium and you'll be able to choose TryClick which will work the same as Click but suppress any errors.

Selenium.prototype.doTryClick = function(locator) {
    try {
        return Selenium.prototype.doClick.call(this,locator);
    } catch(err) { return null; }   
};
like image 86
Patrick64 Avatar answered Jan 23 '23 02:01

Patrick64