def test_updating_profile_picture(self): # Changes profile picture m.more_button().click() m.profile_picture().click() m.change_profile_picture().click() log("Changing profile picture") s.camera_button().click(), sleep(3) driver.press_keycode(25), driver.press_keycode(27), sleep(5) # Takes picture using Android keycode try: driver.find_element_by_id("com.motorola.camera:id/review_approve").click() # For Moto phones except Exception: pass try: driver.find_element_by_id("com.android.camera:id/select_this").click() # For older HTC one phones except Exception: pass try: ta(driver).press(x=1660, y=530).release().perform() # For new HTC One phones except Exception: pass try: driver.find_element_by_name("OK").click() # For Galaxy phones except Exception: pass try: driver.find_element_by_id("com.android.camera2:id/done_button").click() # For Nexus phones except Exception: pass m.profile_picture_done().click(), sleep(3) log("Profile picture updated")
def test_updating_profile_picture(self): # Changes profile picture m.more_button().click() m.profile_picture().click() m.change_profile_picture().click() log("Changing profile picture") s.camera_button().click(), sleep(3) driver.press_keycode(25), driver.press_keycode(27), sleep( 5) # Takes picture using Android keycode try: driver.find_element_by_id("com.motorola.camera:id/review_approve" ).click() # For Moto phones except Exception: pass try: driver.find_element_by_id("com.android.camera:id/select_this" ).click() # For older HTC one phones except Exception: pass try: ta(driver).press( x=1660, y=530).release().perform() # For new HTC One phones except Exception: pass try: driver.find_element_by_name("OK").click() # For Galaxy phones except Exception: pass try: driver.find_element_by_id("com.android.camera2:id/done_button" ).click() # For Nexus phones except Exception: pass m.profile_picture_done().click(), sleep(3) log("Profile picture updated")
def test_sign_up(self): # Creates a new account and tests if special characters can be used s.sign_up_button().click() s.pick_username().send_keys(account_name + "!@#$") try: s.sign_up_OK(5).click() log("Special characters used in username", "Warning") except Exception: log("Could not use special characters in username") s.pick_username().send_keys(account_name) s.sign_up_OK(5).click() s.create_password().send_keys(account_pw) s.confirm_password().send_keys(account_pw) s.password_OK().click() s.birthday().click(), sleep(2) # Sets birthday log("Entering birthday") ta(driver).long_press(x=s.date().location['x'], y=s.date().location['y'], duration=3000).release().perform() s.birthday_done().click() s.birthday_OK().click() # Enters email log("Entering email") s.email().send_keys(account_email) s.email_OK().click() s.OK_button().click()
def test_reply_to_blast(self): # Opens blast and tests reply functionality log("Testing reply functionality") h.swipe_view_reply().click() h.swipe_view_reply().send_keys("Test reply") h.swipe_view_reply_send().click() h.swipe_view_reply().click() h.swipe_view_reply().send_keys(blast_username[:-2]) log("Testing if +usernames can be tapped") h.swipe_view_reblast().click() h.swipe_view_reply_send().click() h.swipe_view_reply_monkey().click() h.swipe_view_monkey().click() h.swipe_view_emoji_cancel().click() h.swipe_view_reply_media().click() log("Testing photo and video replies") h.photo_button().click() h.photo_pen().click() driver.swipe(h.photo_back_button().location['x'] + 50, h.photo_back_button().location['y'] - 50, h.photo_pen().location['x'], h.photo_pen().location['y'] + 50) h.swipe_view_photo_send().click() h.swipe_view_reply_media().click() h.video_button().click() ta(driver).long_press(h.photo_button(), duration=5000).release().perform() h.swipe_view_photo_send().click(), sleep(4) driver.press_keycode(4)
def test_account_deleting(self): log("Deleting") sleep(2) m.more_button().click() driver.scroll(m.friends(), m.back_button()) m.delete_account().click() m.confirm().click() log("Account Deleted") try: if LoginWith().user(account_name, account_pw, driver): ("Logged into deleted account") except Exception: log("Can not login into deleted account") #Recreating the account s.pick_username().send_keys(account_name) s.sign_up_OK(5).click() s.create_password().send_keys(account_pw) s.confirm_password().send_keys(account_pw) s.password_OK().click() s.birthday().click(), sleep(2) log("Entering birthday") ta(driver).long_press(x=s.date().location['x'], y=s.date().location['y'], duration=3000).release().perform() s.birthday_done().click() s.birthday_OK().click() log("Entering email") s.email().send_keys(account_email) s.email_OK().click() s.OK_button().click()
def test_account_creation(self): s = SignUp() # Creates username and password s.sign_up_button().click() s.pick_username().send_keys(account_name) s.sign_up_OK().click() s.create_password().send_keys(account_pw) s.confirm_password().send_keys(account_pw) s.password_OK().click() s.birthday().click(), sleep(2) ta(driver).long_press(x=s.date().location['x'], y=s.date().location['y'], duration=3000).release().perform() s.birthday_done().click() s.birthday_OK().click() # Enters email s.email().send_keys(account_email) s.email_OK().click() s.OK_button().click() # Skips remaining on boarding for i in range(2): s.skip_button().click() s.done_button().click()
def test_reply_to_blast(self): # Opens blast and tests reply functionality log("Testing reply functionality") h.swipe_view_reply().click() h.swipe_view_reply().send_keys("Test reply") h.swipe_view_reply_send().click() h.swipe_view_reply().click() h.swipe_view_reply().send_keys(blast_username[:-2]) log("Testing if +usernames can be tapped") h.swipe_view_reblast().click() h.swipe_view_reply_send().click() h.swipe_view_reply_monkey().click() h.swipe_view_monkey().click() h.swipe_view_emoji_cancel().click() h.swipe_view_reply_media().click() log("Testing photo and video replies") h.photo_button().click() h.photo_pen().click() driver.swipe( h.photo_back_button().location["x"] + 50, h.photo_back_button().location["y"] - 50, h.photo_pen().location["x"], h.photo_pen().location["y"] + 50, ) h.swipe_view_photo_send().click() h.swipe_view_reply_media().click() h.video_button().click() ta(driver).long_press(h.photo_button(), duration=5000).release().perform() h.swipe_view_photo_send().click(), sleep(4) driver.press_keycode(4)
def blast_list_expand(self, wait=30): el = WebDriverWait(driver, wait).until( ec.element_to_be_clickable(( By.XPATH, "//android.widget.ExpandableListView[@index='0'][android.widget.RelativeLayout]" ))) ta(driver).press(x=el.location['x'], y=el.location['y']).release().perform()
def video_blast(): h.action_menu().click() h.action_menu_media().click() h.video_button().click() ta(driver).long_press(h.photo_button(), duration=8000).release().perform() h.next_button().click() h.blast_friends().click() h.username(blast_recipient).click() h.blast_Ok_button().click()
def send_video_no_loc(self): log("Sending video blasts without location") for i in range(3): h.action_menu().click() h.action_menu_media().click() h.video_button().click() ta(driver).long_press(h.photo_button(), duration=5000).release().perform() h.next_button().click() h.blast_friends().click() h.username(account02).click() h.blast_Ok_button().click()
def test_opening_text_blast(self): # Login as account02 LoginWith().user(account02, password02, driver) # Opens text blast with +username, URL, and location log("Opening text blast and checking +username, URL, and location") h.name(account01).click(), sleep(2) h.swipe_view_location().click(), sleep(3), driver.press_keycode(4), sleep(2) ta(driver).press(x=sw * 0.17, y=sh * 0.23).release().perform() # clicks +username h.swipe_view_add().click(), sleep(2) h.swipe_view_url_card().click(), sleep(4) h.back_button().click(), sleep(1) driver.swipe(sw * 0.800, sh * 0.300, sw * 0.100, sh * 0.300, 300)
def test_sending_video_blast_02(self): # Takes video, adds URL, then sends to single friend log("Sending video with URL") h.action_menu().click() h.action_menu_media().click() h.video_button().click() ta(driver).long_press(h.photo_button(), duration=5000).release().perform() h.add_text().click() h.add_text_field().send_keys(blast_url) h.done_button().click() h.next_button().click() h.blast_friends().click() h.username(account02).click() h.blast_Ok_button().click()
def test_opening_text_blast(self): # Login as account02 LoginWith().user(account02, password02, driver) # Opens text blast with +username, URL, and location log("Opening text blast and checking +username, URL, and location") h.name(account01).click(), sleep(2) h.swipe_view_location().click(), sleep(3), driver.press_keycode(4), sleep(2) ta(driver).press(x=sw * .17, y=sh * .23).release().perform() # clicks +username h.swipe_view_add().click(), sleep(2) h.swipe_view_url_card().click(), sleep(4) h.back_button().click(), sleep(1) driver.swipe(sw * .800, sh * .300, sw * .100, sh * .300, 300)
def test_profile_picture(self): # Takes a picture with camera and sets as profile picture s.profile_picture().click() log("Taking a photo and setting it as the profile picture") s.camera_button().click(), sleep(3) driver.press_keycode(25), sleep(1), driver.press_keycode(27), sleep( 5) # Takes picture using Android keycode try: driver.find_element_by_id("com.motorola.camera:id/review_approve" ).click() # For Moto phones except Exception: pass try: driver.find_element_by_id("com.android.camera:id/select_this" ).click() # For older HTC one phones except Exception: pass try: ta(driver).press( x=1660, y=530).release().perform() # For new HTC One phones except Exception: pass try: driver.find_element_by_name("OK").click() # For Galaxy phones except Exception: pass try: driver.find_element_by_id("com.android.camera2:id/done_button" ).click() # For Nexus phones except Exception: pass try: m.profile_picture_done(5).click(), sleep(3) except Exception: log("Could not take a photo, going back", "Warning") for i in range(2): driver.press_keycode(4), sleep( 1) # If none of the above works, go back s.skip_button() log("Skipping checking contacts and sending text message") s.OK_button().click() s.skip_button().click() s.done_button().click() log("New account, %s, created" % account_name)
def test_sending_video_blast_01(self): # Takes video, adds +username, creates blast list, then sends to that blast list log("Sending video to newly created blast list") h.action_menu().click() h.action_menu_media().click() h.video_button().click() ta(driver).long_press(h.photo_button(), duration=5000).release().perform() h.add_text().click() h.add_text_field().send_keys(blast_username) h.done_button().click() h.next_button().click() h.create_blast_list().click() h.blast_list_field().send_keys("My Test List") h.OK_button().click() h.username(account02).click() h.username(account03).click() h.OK_button().click() h.send_to_blast_list().click() h.blast_Ok_button().click()
def test_profile_picture(self): # Takes a picture with camera and sets as profile picture s.profile_picture().click() log("Taking a photo and setting it as the profile picture") s.camera_button().click(), sleep(3) driver.press_keycode(25), sleep(1), driver.press_keycode(27), sleep(5) # Takes picture using Android keycode try: driver.find_element_by_id("com.motorola.camera:id/review_approve").click() # For Moto phones except Exception: pass try: driver.find_element_by_id("com.android.camera:id/select_this").click() # For older HTC one phones except Exception: pass try: ta(driver).press(x=1660, y=530).release().perform() # For new HTC One phones except Exception: pass try: driver.find_element_by_name("OK").click() # For Galaxy phones except Exception: pass try: driver.find_element_by_id("com.android.camera2:id/done_button").click() # For Nexus phones except Exception: pass try: m.profile_picture_done(5).click(), sleep(3) except Exception: log("Could not take a photo, going back", "Warning") for i in range(2): driver.press_keycode(4), sleep(1) # If none of the above works, go back s.skip_button() log("Skipping checking contacts and sending text message") s.OK_button().click() s.skip_button().click() s.done_button().click() log("New account, %s, created" % account_name)
def blast_list_expand(self, wait=30): el = WebDriverWait(driver, wait).until(ec.element_to_be_clickable((By.XPATH, "//android.widget.ExpandableListView[@index='0'][android.widget.RelativeLayout]"))) ta(driver).press(x=el.location['x'], y=el.location['y']).release().perform()