New e2e test to set image from Galary and Photo

Signed-off-by: Serhy <sergii@status.im>
This commit is contained in:
Serhy 2021-02-23 14:19:55 +02:00
parent f0d79f3af0
commit d5e1d3fe65
No known key found for this signature in database
GPG Key ID: 5D7C4B9E2B6F500B
6 changed files with 85 additions and 23 deletions

View File

@ -554,20 +554,6 @@ class TestProfileSingleDevice(SingleDeviceTestCase):
self.errors.verify_no_errors() self.errors.verify_no_errors()
@marks.testrail_id(5302)
@marks.high
@marks.skip
# TODO: skip until profile picture change feature is enabled
def test_set_profile_picture(self):
sign_in_view = SignInView(self.driver)
sign_in_view.create_user()
profile_view = sign_in_view.profile_button.click()
profile_view.edit_profile_picture(file_name='sauce_logo.png')
profile_view.home_button.click()
sign_in_view.profile_button.click()
profile_view.swipe_down()
if not profile_view.profile_picture.is_element_image_equals_template('sauce_logo_profile.png'):
self.driver.fail('Profile picture was not updated')
@marks.testrail_id(5475) @marks.testrail_id(5475)
@marks.low @marks.low
@ -622,6 +608,45 @@ class TestProfileSingleDevice(SingleDeviceTestCase):
class TestProfileMultipleDevice(MultipleDeviceTestCase): class TestProfileMultipleDevice(MultipleDeviceTestCase):
@marks.testrail_id(6646)
@marks.high
def test_set_profile_picture(self):
self.create_drivers(2)
home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user()
profile_1 = home_1.profile_button.click()
public_key_1 = profile_1.get_public_key_and_username()
profile_1.just_fyi("Set user Profile image from Gallery")
profile_1.edit_profile_picture(file_name='sauce_logo.png')
home_1.profile_button.click()
profile_1.swipe_down()
if not profile_1.profile_picture.is_element_image_similar_to_template('sauce_logo_profile.png'):
self.drivers[0].fail('Profile picture was not updated')
profile_1.just_fyi("Check user profile updated in chat")
home = profile_1.home_button.click()
message = "Text message"
public_chat_name = home.get_random_chat_name()
home_2.add_contact(public_key=public_key_1)
home_2.home_button.click()
public_chat_2 = home_2.join_public_chat(public_chat_name)
public_chat_1 = home.join_public_chat(public_chat_name)
public_chat_1.chat_message_input.send_keys(message)
public_chat_1.send_message_button.click()
if not public_chat_2.chat_element_by_text(message).member_photo.is_element_image_similar_to_template('sauce_logo.png'):
self.drivers[0].fail('Profile picture was not updated in chat')
profile_1.just_fyi("Set user Profile image by taking Photo")
home_1.profile_button.click()
profile_1.edit_profile_picture(file_name='sauce_logo.png', update_by='Make Photo')
home_1.home_button.click(desired_view='chat')
public_chat_1.chat_message_input.send_keys(message)
public_chat_1.send_message_button.click()
if public_chat_2.chat_element_by_text(message).member_photo.is_element_image_similar_to_template('sauce_logo.png'):
self.drivers[0].fail('Profile picture was not updated in chat after making photo')
@marks.testrail_id(5432) @marks.testrail_id(5432)
@marks.medium @marks.medium
def test_custom_bootnodes(self): def test_custom_bootnodes(self):

View File

@ -77,7 +77,6 @@ class TestDApps(SingleDeviceTestCase):
camera_dapp.browser_refresh_page_button.click() camera_dapp.browser_refresh_page_button.click()
camera_dapp.allow_button.click() camera_dapp.allow_button.click()
if camera_dapp.camera_image_in_dapp.is_element_image_similar_to_template('blank_camera_image.png'): if camera_dapp.camera_image_in_dapp.is_element_image_similar_to_template('blank_camera_image.png'):
camera_dapp.camera_image_in_dapp.save_new_screenshot_of_element('blank_camera_image3.png')
self.driver.fail("Even camera access Accepted to Dapp, - camera view is not shown") self.driver.fail("Even camera access Accepted to Dapp, - camera view is not shown")
camera_dapp.just_fyi("Relogin and check camera access still needs to be allowed") camera_dapp.just_fyi("Relogin and check camera access still needs to be allowed")

View File

@ -28,6 +28,7 @@ class BaseElement(object):
self.suffix = None self.suffix = None
self.id = None self.id = None
self.class_name = None self.class_name = None
self.AndroidUIAutomator = None
self.webview = None self.webview = None
self.__dict__.update(kwargs) self.__dict__.update(kwargs)
@ -52,6 +53,9 @@ class BaseElement(object):
elif self.class_name: elif self.class_name:
self.by = MobileBy.CLASS_NAME self.by = MobileBy.CLASS_NAME
self.locator = self.class_name self.locator = self.class_name
elif self.AndroidUIAutomator:
self.by = MobileBy.ANDROID_UIAUTOMATOR
self.locator = self.AndroidUIAutomator
elif self.webview: elif self.webview:
self.locator = '//*[@text="{0}"] | //*[@content-desc="{desc}"]'.format(self.webview, desc=self.webview) self.locator = '//*[@text="{0}"] | //*[@content-desc="{desc}"]'.format(self.webview, desc=self.webview)
if self.prefix: if self.prefix:

View File

@ -215,6 +215,7 @@ class BaseView(object):
self.no_button = Button(self.driver, translation_id="no") self.no_button = Button(self.driver, translation_id="no")
self.back_button = BackButton(self.driver) self.back_button = BackButton(self.driver)
self.allow_button = AllowButton(self.driver) self.allow_button = AllowButton(self.driver)
self.allow_all_the_time = Button(self.driver, xpath="//*[@text='Allow all the time']")
self.deny_button = Button(self.driver, translation_id="deny", uppercase=True) self.deny_button = Button(self.driver, translation_id="deny", uppercase=True)
self.continue_button = Button(self.driver, translation_id="continue", uppercase=True) self.continue_button = Button(self.driver, translation_id="continue", uppercase=True)
self.ok_button = Button(self.driver, xpath="//*[@text='OK' or @text='Ok']") self.ok_button = Button(self.driver, xpath="//*[@text='OK' or @text='Ok']")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -171,6 +171,11 @@ class ProfileView(BaseView):
self.confirm_edit_button = Button(self.driver, accessibility_id="done-button") self.confirm_edit_button = Button(self.driver, accessibility_id="done-button")
self.select_from_gallery_button = Button(self.driver, translation_id="profile-pic-pick") self.select_from_gallery_button = Button(self.driver, translation_id="profile-pic-pick")
self.capture_button = Button(self.driver, translation_id="image-source-make-photo") self.capture_button = Button(self.driver, translation_id="image-source-make-photo")
self.take_photo_button = Button(self.driver, accessibility_id="take-photo")
self.crop_photo_button = Button(self.driver, accessibility_id="Crop")
self.decline_photo_crop = Button(self.driver, accessibility_id="Navigate up")
self.shutter_button = Button(self.driver, accessibility_id="Shutter")
self.accept_photo_button = Button(self.driver, accessibility_id="Done")
# ENS # ENS
self.username_in_ens_chat_settings_text = EditBox(self.driver, self.username_in_ens_chat_settings_text = EditBox(self.driver,
@ -327,20 +332,45 @@ class ProfileView(BaseView):
self.driver.info("**Seed phrase is backed up!**") self.driver.info("**Seed phrase is backed up!**")
return recovery_phrase return recovery_phrase
def edit_profile_picture(self, file_name: str): def edit_profile_picture(self, file_name: str, update_by = "Gallery"):
self.driver.info("**Setting custom profile image**")
if not AbstractTestCase().environment == 'sauce': if not AbstractTestCase().environment == 'sauce':
raise NotImplementedError('Test case is implemented to run on SauceLabs only') raise NotImplementedError('Test case is implemented to run on SauceLabs only')
self.profile_picture.click() self.profile_picture.click()
self.profile_picture.template = file_name self.profile_picture.template = file_name
self.select_from_gallery_button.click() if update_by == "Gallery":
self.select_from_gallery_button.click()
if self.allow_button.is_element_displayed(sec=5):
self.allow_button.click()
image_name = "sauce_logo.png, 4.64 kB, Nov 4, 2020"
if file_name == 'sauce_logo_red.png':
image_name = "sauce_logo_red.png, 624 kB, Nov 4, 2020"
image_full_content = self.get_image_in_storage_by_name(image_name)
if not image_full_content.is_element_displayed(2):
self.show_roots_button.click()
for element_text in 'Images', 'DCIM':
self.element_by_text(element_text).click()
image_full_content.click()
else:
## take by Photo
self.take_photo()
self.click_system_back_button()
self.take_photo()
self.accept_photo_button.click()
self.crop_photo_button.click()
self.driver.info("**Custom profile image has been set**")
def take_photo(self):
self.take_photo_button.click()
if self.allow_button.is_element_displayed(sec=5): if self.allow_button.is_element_displayed(sec=5):
self.allow_button.click() self.allow_button.click()
picture = self.element_by_text(file_name) if self.allow_all_the_time.is_element_displayed(sec=5):
if not picture.is_element_displayed(2): self.allow_all_the_time.click()
self.show_roots_button.click() if self.element_by_text("NEXT").is_element_displayed(sec=5):
for element_text in 'Images', 'DCIM': self.element_by_text("NEXT").click()
self.element_by_text(element_text).click() self.shutter_button.click()
picture.click()
def logout(self): def logout(self):
self.driver.info("**Logging out**") self.driver.info("**Logging out**")
@ -351,6 +381,9 @@ class ProfileView(BaseView):
def mail_server_by_name(self, server_name): def mail_server_by_name(self, server_name):
return MailServerElement(self.driver, server_name) return MailServerElement(self.driver, server_name)
def get_image_in_storage_by_name(self, image_name=str()):
return SilentButton(self.driver, xpath="//*[@content-desc='%s']" % image_name)
def get_toggle_device_by_name(self, device_name): def get_toggle_device_by_name(self, device_name):
self.driver.info("**Selecting device %s for sync**" % device_name) self.driver.info("**Selecting device %s for sync**" % device_name)
return SilentButton(self.driver, xpath="//android.widget.TextView[contains(@text,'%s')]/..//android.widget.CheckBox" % device_name) return SilentButton(self.driver, xpath="//android.widget.TextView[contains(@text,'%s')]/..//android.widget.CheckBox" % device_name)