I'm learning about the Selenium web drivers and have started using python to test websites. I'm having issues with the wait for element not to be present code, as it seems to be timing out.
This is the code I have so far.
def test_(self):
driver = self.driver
driver.get(self.base_url + "/srs")
driver.find_element_by_id("UserName").clear()
driver.find_element_by_id("UserName").send_keys("mnoriega")
driver.find_element_by_id("Password").clear()
driver.find_element_by_id("Password").send_keys("sbyprod")
driver.find_element_by_id("loginbutton").click()
for i in range(60):
try:
if not self.is_element_present(By.CSS_SELECTOR, ".blockUI"): break
except: pass
time.sleep(1)
else: self.fail("time out")
driver.find_element_by_xpath(".//*[@id='ChangeTaskGridM']/table/thead/tr/th[1]/a").click()
for i in range(60):
try:
if not self.is_element_present(By.CSS_SELECTOR, ".blockUI"): break
except: pass
time.sleep(1)
else: self.fail("time out")
driver.find_element_by_xpath(".//*[@id='ChangeTaskGridM']/table/thead/tr/th[2]/a").click()
for i in range(60):
try:
if not self.is_element_present(By.CSS_SELECTOR, ".blockUI"): break
except: pass
time.sleep(1)
else: self.fail("time out")
I'm not sure why it's timing out. If I remove the blockUI it will run to fast and I also don't want to put manual breaks in between. Any ideas?
Current code to detect is_element_present
for i in range(60):
try:
if not self.is_element_present(By.CSS_SELECTOR, ".blockUI"): break
except: pass
time.sleep(1)
else: self.fail("time out")
Aucun commentaire:
Enregistrer un commentaire