I'm writting some scripts on Selenium combined with Saucelab. However I have an issue. I do a test condition to know if I have an element or not on my page, if there is not this element I want to stop the test and send a fail flag to Saucelab.
My code is:
if (len(driver.find_elements_by_xpath("//div[@data-user-id='34196'][@data-shift-date='%s']/div/div[@class='shift-details']" %date))!=0 ): print "The shift is assigned to this user, good" else: print "The shift is not assigned to this user, issue" sauce_client.jobs.update_job(driver.session_id, passed=False) driver.quit() sauce_client.jobs.update_job(driver.session_id, passed=True) driver.quit()
My problem is that
driver.quit() in the else part doesn't work as I would like. The script is still running.