From 28c5ef89f772d618e4dbefbd216a173b5037529b Mon Sep 17 00:00:00 2001 From: Dennis <52335835+mastrolube@users.noreply.github.com> Date: Sun, 1 Nov 2020 12:23:12 +0100 Subject: [PATCH 1/3] fix one accidentally scroll down in unfollow process fix one accidentally scroll down in unfollow process. it works but i think mine is a noob code :) --- src/action_unfollow.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/action_unfollow.py b/src/action_unfollow.py index 6ff9797e..98d1503e 100644 --- a/src/action_unfollow.py +++ b/src/action_unfollow.py @@ -163,9 +163,21 @@ def _do_unfollow(device, username, my_username, check_if_is_follower): device.back() return False - unfollow_button = device.find( - classNameMatches=TEXTVIEW_OR_BUTTON_REGEX, clickable=True, text="Following" - ) + attemp = 0 + + while True: + unfollow_button = device.find( + classNameMatches=TEXTVIEW_OR_BUTTON_REGEX, clickable=True, text="Following" + ) + if not unfollow_button.exists() and attemp <= 1: + scrollable = device.find( + classNameMatches="androidx.viewpager.widget.ViewPager" + ) + scrollable.scroll(DeviceFacade.Direction.TOP) + attemp += 1 + else: + break + if not unfollow_button.exists(): print( COLOR_FAIL @@ -175,6 +187,7 @@ def _do_unfollow(device, username, my_username, check_if_is_follower): save_crash(device) switch_to_english(device) raise LanguageChangedException() + unfollow_button.click() confirm_unfollow_button = device.find( From a1cd660fe1e16bfd2b0494c1f9c39dbe3c1b1fc4 Mon Sep 17 00:00:00 2001 From: Dennis <52335835+mastrolube@users.noreply.github.com> Date: Sun, 1 Nov 2020 12:25:47 +0100 Subject: [PATCH 2/3] forgot fo black .. --- src/action_unfollow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/action_unfollow.py b/src/action_unfollow.py index 98d1503e..1efea112 100644 --- a/src/action_unfollow.py +++ b/src/action_unfollow.py @@ -171,13 +171,13 @@ def _do_unfollow(device, username, my_username, check_if_is_follower): ) if not unfollow_button.exists() and attemp <= 1: scrollable = device.find( - classNameMatches="androidx.viewpager.widget.ViewPager" + classNameMatches="androidx.viewpager.widget.ViewPager" ) scrollable.scroll(DeviceFacade.Direction.TOP) attemp += 1 else: break - + if not unfollow_button.exists(): print( COLOR_FAIL From 5570e1da071a0678cad23309a90448e99ff69807 Mon Sep 17 00:00:00 2001 From: Philip Ulrich Date: Mon, 2 Nov 2020 19:29:10 -0600 Subject: [PATCH 3/3] fixing "attemp" typo - it was bugging me --- src/action_unfollow.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/action_unfollow.py b/src/action_unfollow.py index 1efea112..da77f6fa 100644 --- a/src/action_unfollow.py +++ b/src/action_unfollow.py @@ -163,18 +163,18 @@ def _do_unfollow(device, username, my_username, check_if_is_follower): device.back() return False - attemp = 0 + attempts = 0 while True: unfollow_button = device.find( classNameMatches=TEXTVIEW_OR_BUTTON_REGEX, clickable=True, text="Following" ) - if not unfollow_button.exists() and attemp <= 1: + if not unfollow_button.exists() and attempts <= 1: scrollable = device.find( classNameMatches="androidx.viewpager.widget.ViewPager" ) scrollable.scroll(DeviceFacade.Direction.TOP) - attemp += 1 + attempts += 1 else: break