def main(): link1 = "http://suninjuly.github.io/selects1.html" link2 = "http://suninjuly.github.io/selects2.html" link_answer = "https://stepik.org/lesson/228249/step/3?unit=200781" browser = webdriver.Firefox() try: # get verification code answer_value = les2_3_dropdown.main(browser, link1) # log in les1_0_stepik_login.main(browser) time.sleep(1) # send answer les1_0_stepik_answer.main(browser, link_answer, answer_value) time.sleep(1) except Exception as error: print(f'Произошла ошибка, вот её трэйсбэк: {error}') finally: time.sleep(1) # close browser browser.quit()
def main(): link = "http://suninjuly.github.io/math.html" link_answer = "https://stepik.org/lesson/165493/step/5?unit=140087" browser = webdriver.Firefox() try: # get verification code answer_value = les1_5_capcha_for_robots.main(browser, link) # log in les1_0_stepik_login.main(browser) time.sleep(1) # send answer les1_0_stepik_answer.main(browser, link_answer, answer_value) time.sleep(1) finally: time.sleep(1) # close browser browser.quit()
def main(): link = "http://suninjuly.github.io/redirect_accept.html" link_answer = "https://stepik.org/lesson/184253/step/6?unit=158843" browser = webdriver.Firefox() try: # get verification code answer_value = les3_6_move_to_new_tab.main(browser, link) # log in les1_0_stepik_login.main(browser) time.sleep(1) # send answer les1_0_stepik_answer.main(browser, link_answer, answer_value) time.sleep(1) except Exception as error: print(f'Произошла ошибка, вот её трэйсбэк: {error}') finally: time.sleep(1) # close browser browser.quit()
# из алерта получаем ответ alert = browser.switch_to.alert text_alert = alert.text answer = text_alert[(text_alert.index(': ')) + 2:] alert.accept() return answer link = "https://suninjuly.github.io/explicit_wait2.html" link_answer = "https://stepik.org/lesson/181384/step/8?unit=156009" browser = webdriver.Firefox() browser.implicitly_wait(5) try: # get verification code answer_value = wait_text(browser, link) print("Answer -", answer_value) # log in les1_0_stepik_login.main(browser) # send answer les1_0_stepik_answer.main(browser, link_answer, answer_value) finally: time.sleep(1) # close browser print("Close browser.") browser.quit()