unit testing - Selenium running same test twice when executed from withing a script - Python -
i have python script runs different selenium webdrivers have been exported python. script , webdrivers want them do. when script executes webdriver, webdriver needs go , continue script pause , firefox pop again , execute same webdriver task again. doesn't affect results webdrivers or script increases run-time significantly.
after first exectution of webdriver shell return:
ran 1 test in 192.680s ok
however, when repeats webdriver unexpectedly returns period "."
here code webdriver,
from selenium import webdriver selenium.webdriver.common.by import selenium.webdriver.support.ui import select selenium.common.exceptions import nosuchelementexception import unittest, time, re class webdriverviewas(unittest.testcase): def setup(self): self.driver = webdriver.firefox() self.driver.implicitly_wait(30) self.base_url = #website i'm interested in visiting self.verificationerrors = [] self.accept_next_alert = true def test_webdriver_viewas(self): #here tell webdriver do, doubt causing problem def is_element_present(self, how, what): try: self.driver.find_element(by=how, value=what) except nosuchelementexception, e: return false return true def is_alert_present(self): try: self.driver.switch_to_alert() except noalertpresentexception, e: return false return true def close_alert_and_get_its_text(self): try: alert = self.driver.switch_to_alert() alert_text = alert.text if self.accept_next_alert: alert.accept() else: alert.dismiss() return alert_text finally: self.accept_next_alert = true def teardown(self): self.driver.quit() self.assertequal([], self.verificationerrors) if __name__=='__main__': try: unittest.main() except systemexit inst: if inst.args[0] true: # raised sys.exit(true) when tests failed raise
i suspected problem solved unittest module i've found nothing in research i've done nor have been able find similar problem.
Comments
Post a Comment