Reset the driver execution state to a particular point in test case - Selenium

32 views
Skip to first unread message

Kesiya Abraham

unread,
Jun 30, 2020, 10:26:21 AM6/30/20
to Selenium Users

I am trying to achieve the reset functionality in test cases where the automation tool used is selenium.

The scenario is, I have a test case,

  1. Go to the URL specified
  2. Type username and password fields
  3. Click on submit button
  4. Type 'some value' in a textbox
  5. Click on a button
  6. Pop up a window
  7. Check the title

Here, I have to make a retry on the commands starting from step 4 to step 7. Suppose, I have to retry these commands 2 times and once the control goes to step 7 and title is not present, I have to reset the driver execution status exactly to point step 4 and should be able to retry the same steps again.

I am not able to find a reset command from selenium documentation. Could anyone please help me to achieve the same?

Thanks in advance for all comments!

Adrian

unread,
Jun 30, 2020, 5:18:44 PM6/30/20
to Selenium Users

Hi Keyisa,
What are you trying to achieve?
It sounds like the title is not present after you have performed some steps, so you want to do the exact same thing again and check to see if the title matches.
Is that what you are doing?

If this is true, then I think you have timing issue.  If the pop up window exists then it should have a title otherwise the test should fail.
If the test fails and you can see a title on the pop up then in step 7 you need to wait until the title exists.  If after your wait time the title does not exist or is incorrect, then fail the test.

Restarting from step 4 sounds like the wrong thing to do.

Regards,
Adrian.

Gaurav Pandey

unread,
Jul 6, 2020, 7:34:39 AM7/6/20
to Selenium Users
You probably may want to consider using text fixtures - TestNg and Junit are quite popular. 
For instance in Junit - 

@Before All
<<code for launch and login>>

test()
<<code for the test

@AfterEach
<<code for log off and exit browser>>

if you follow the above structure - @AfterEach will run irrespective of whatever is the status of test()

in Java, the concept of BaseTest is quite popular as well.

Do consider. 
Reply all
Reply to author
Forward
0 new messages