Skip to content

Commit

Permalink
Fix bug with accidental back click when liking post
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed Jun 1, 2020
1 parent cea6d7c commit e151b7f
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions insomniac.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def iterate_over_followers(device, interaction, total_likes_limit, interactions_
print "Reached total likes limit."
print_report_and_quit()

print "Back to followers list"
device.press.back()

if len(iterated_followers) > 0:
Expand Down Expand Up @@ -250,21 +251,29 @@ def open_photo():
className='android.widget.FrameLayout')
random_sleep()

action_bar = device(resourceId='com.instagram.android:id/action_bar_container',
className='android.widget.FrameLayout')
action_bar_bottom = action_bar.bounds['bottom']

# If double click didn't work, set like by icon click
try:
like_image = device(resourceId='com.instagram.android:id/row_feed_button_like',
className='android.widget.ImageView',
selected=False)
like_image.click()
print "Double click didn't work, click on icon."
# Click only button which is under the action bar. It fixes bug with accidental back icon click
for like_button in device(resourceId='com.instagram.android:id/row_feed_button_like',
className='android.widget.ImageView',
selected=False):
like_button_top = like_button.bounds['top']
if like_button_top > action_bar_bottom:
print "Double click didn't work, click on icon."
like_button.click()
except uiautomator.JsonRPCError:
print "Double click worked successfully."
finally:
global totalLikes
totalLikes += 1
random_sleep()
device.press.back()
return True

global totalLikes
totalLikes += 1
random_sleep()
print "Back to profile"
device.press.back()
return True


def scroll_profile(device):
Expand Down

0 comments on commit e151b7f

Please sign in to comment.