MCPcopy
hub / github.com/InstaPy/InstaPy / confirm_unfollow

Function confirm_unfollow

instapy/unfollow_util.py:1413–1437  ·  view source on GitHub ↗

Deal with the confirmation dialog boxes during an unfollow

(browser)

Source from the content-addressed store, hash-verified

1411
1412
1413def 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
1440def post_unfollow_cleanup(

Callers 2

unfollow_userFunction · 0.85
verify_actionFunction · 0.85

Calls 3

read_xpathFunction · 0.85
click_elementFunction · 0.85
sleepFunction · 0.85

Tested by

no test coverage detected