2

Im using WebDriver and Python to automate a website. I have a suite of tests and sometimes running into the following problem.

Test no.1 = Login to home page, navigate to Account page, perform some activity, Logout
Test no.2 = Login to home page, navigate to Deposit page, perform some activity, Logout

Problem: If Test no.1 has a catastrophic failure in Account page, then when Test no.2 kicks off, it logins to the account page instead of the home page.

Question: How do I make sure that every test starts with a clean session, i.e. login always goes to the home page?

Clearing the browser cookies and cache doesn't help. I have in my Test Teardown, the Close All Browsers keyword which clears the browser cache and closes the browsers.

  • This question has the robotframework tag, but this question appears to have nothing to do at all with robotframework. – Bryan Oakley Aug 9 '14 at 12:24
0

I suggest you simply driver.get(URL) to your homepage. Not sure why you consider a hack, if that is what you need to recover from test failure.

  • Hi Peter, I guess I could force the homepage on the second login. But that would look like a hack. – Haris Jul 17 '14 at 0:18
  • This should be a comment, not an answer. Could you please repost as a comment and delete your answer? – Kate Paulk Jul 17 '14 at 10:44
  • Hi Kate, I think thats what I did. I clicked the <Add Comment> button to respond. Sorry this is my first time with StackExchange. – Haris Jul 17 '14 at 16:56
  • Thanks Peter. I guess I could simply update the keyword to switch to the home page if login lands elsewhere. – Haris Jul 17 '14 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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