From 8b94ba25fd489ba5705e6971ef600c0bed036c46 Mon Sep 17 00:00:00 2001 From: naisanzaa Date: Wed, 9 Oct 2024 06:23:51 +0800 Subject: [PATCH] facebook: remove xpaths in preference for a more flexible search --- automon/integrations/facebook/groups.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/automon/integrations/facebook/groups.py b/automon/integrations/facebook/groups.py index d3c1668d..62b33e7d 100644 --- a/automon/integrations/facebook/groups.py +++ b/automon/integrations/facebook/groups.py @@ -264,7 +264,7 @@ def privacy_details(self): try: known_privacy_details = [ - 'Anyone can find this group.' + "Anyone can see who's in the group and what they post.", ] for privacy_details in known_privacy_details: @@ -316,7 +316,21 @@ def url_cleaner(url: str): def visible(self) -> str: try: - text = self._browser.wait_for_anything(self._xpath_visible) + known_visible = [ + 'Anyone can find this group.', + ] + + for visible in known_visible: + text = self._browser.wait_for_anything( + match=visible, + value='span', + by=self._browser.by.TAG_NAME, + exact_match=True + ) + if text: + break + + text = text[-1] text = text.text logger.debug(text) return text