From 34bb78a127076c5b634f2cd7ca5e37fff01bbd08 Mon Sep 17 00:00:00 2001 From: wes Date: Sun, 23 Aug 2020 20:27:08 -0400 Subject: [PATCH] fix timestamp selection --- deletefb/tools/wall.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/deletefb/tools/wall.py b/deletefb/tools/wall.py index 53e7c00..8cc4d27 100644 --- a/deletefb/tools/wall.py +++ b/deletefb/tools/wall.py @@ -39,6 +39,10 @@ def delete_posts(driver, confirmation_button_exp = "//div[contains(@data-sigil, 'undo-content')]//*/a[contains(@href, 'direct_action_execute')]" + # Cannot return a text node, so it returns the parent. + # Tries to be pretty resilient against DOM re-organizations + timestamp_exp = "//article//*/header//*/div/a[contains(@href, 'story_fbid')]//text()/.." + button_types = ["Delete post", "Remove Tag", "Hide from timeline"] while True: @@ -51,7 +55,7 @@ def delete_posts(driver, break post_content_element = driver.find_element_by_xpath("//article/div[@class='story_body_container']/div") - post_content_ts = driver.find_element_by_xpath("//article//*/header//a[contains(@href, 'story')]") + post_content_ts = driver.find_element_by_xpath(timestamp_exp) if not (post_content_element or post_content_ts): break @@ -67,10 +71,13 @@ def delete_posts(driver, actions = ActionChains(driver) actions.move_to_element(timeline_element).click().perform() + # Wait until the buttons show up wait_xpath(driver, "//*[contains(@data-sigil, 'removeStoryButton')]") delete_button = None + # Search for visible buttons in priority order + # Delete -> Untag -> Hide for button_type in button_types: try: delete_button = driver.find_element_by_xpath("//*[text()='{0}']".format(button_type))