Deal with the confirmation dialog boxes during an unfollow
(browser)
| 1411 | |
| 1412 | |
| 1413 | def confirm_unfollow(browser): |
| 1414 | """Deal with the confirmation dialog boxes during an unfollow""" |
| 1415 | attempt = 0 |
| 1416 | |
| 1417 | while attempt < 3: |
| 1418 | try: |
| 1419 | attempt += 1 |
| 1420 | button_xp = read_xpath( |
| 1421 | confirm_unfollow.__name__, "button_xp" |
| 1422 | ) # "//button[contains( |
| 1423 | # text(), 'Unfollow')]" |
| 1424 | unfollow_button = browser.find_element(By.XPATH, button_xp) |
| 1425 | |
| 1426 | if unfollow_button.is_displayed(): |
| 1427 | click_element(browser, unfollow_button) |
| 1428 | sleep(2) |
| 1429 | break |
| 1430 | |
| 1431 | except (ElementNotVisibleException, NoSuchElementException) as exc: |
| 1432 | # prob confirm dialog didn't pop up |
| 1433 | if isinstance(exc, ElementNotVisibleException): |
| 1434 | break |
| 1435 | |
| 1436 | elif isinstance(exc, NoSuchElementException): |
| 1437 | sleep(1) |
| 1438 | |
| 1439 | |
| 1440 | def post_unfollow_cleanup( |
no test coverage detected