Last active
October 5, 2017 08:57
-
-
Save danyashorokh/882cbe6eabc447f3bbdce13619c4d637 to your computer and use it in GitHub Desktop.
[Python] [Selenium] Waiting for form using Selenium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def wait_form(driver, type, path, one_time, max_time, final_text): | |
flag1 = 0 | |
while (True): | |
if flag1 == max_time: | |
print(final_text + "\n") | |
break | |
driver.close() | |
sys.exit(1) | |
else: | |
try: | |
if type == "xpath": | |
driver.find_element_by_xpath(path).click() | |
if type == "id": | |
driver.find_element_by_id(path).click() | |
break | |
except ElementNotVisibleException: # NoSuchElementException: | |
time.sleep(one_time) | |
flag1 += 1 | |
except NoSuchElementException: | |
time.sleep(one_time) | |
flag1 += max_time | |
final_text += u" - Элемент не найден\n" | |
if flag1 > 1: | |
print(u"Ожидали %d раз(а) по %d секунды" % (flag1, one_time)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment