Example #1
0
    def test_element_find_multiple_elements(self):
        wait_for_element(self.driver, MobileBy.CLASS_NAME,
                         'android.widget.ListView')
        el = self.driver.find_element_by_class_name('android.widget.ListView')

        sub_els = el.find_elements_by_accessibility_id('Animation')
        self.assertIsInstance(sub_els, list)
Example #2
0
 def test_find_multiple_elements_by_image_just_returns_one(self) -> None:
     wait_for_element(self.driver, MobileBy.ACCESSIBILITY_ID, "App")
     image_path = desired_capabilities.PATH(
         'file/find_by_image_success.png')
     els = self.driver.find_elements_by_image(image_path)
     els[0].click()
     wait_for_element(self.driver, MobileBy.ACCESSIBILITY_ID, "Alarm")
Example #3
0
 def test_find_single_element(self):
     wait_for_element(self.driver, MobileBy.ANDROID_UIAUTOMATOR,
                      'new UiSelector().text("Accessibility")').click()
     wait_for_element(
         self.driver, MobileBy.ANDROID_UIAUTOMATOR,
         'new UiSelector().text("Accessibility Node Querying")').click()
     el = wait_for_element(self.driver, MobileBy.ACCESSIBILITY_ID,
                           'Task Take out Trash')
     self.assertIsNotNone(el)
    def test_element_find_single_element(self) -> None:
        wait_for_element(self.driver, MobileBy.ANDROID_UIAUTOMATOR,
                         'new UiSelector().text("Accessibility")').click()
        wait_for_element(
            self.driver, MobileBy.ANDROID_UIAUTOMATOR,
            'new UiSelector().text("Accessibility Node Querying")').click()
        el = wait_for_element(self.driver, MobileBy.CLASS_NAME,
                              'android.widget.ListView')

        sub_el = el.find_element_by_accessibility_id('Task Take out Trash')
        assert sub_el is not None
Example #5
0
    def test_find_throws_no_such_element(self) -> None:
        image_path = desired_capabilities.PATH(
            'file/find_by_image_failure.png')
        with open(image_path, 'rb') as png_file:
            b64_data = base64.b64encode(png_file.read()).decode('UTF-8')

        with pytest.raises(TimeoutException):
            wait_for_element(self.driver, MobileBy.IMAGE, b64_data, timeout=3)

        with pytest.raises(NoSuchElementException):
            self.driver.find_element_by_image(image_path)
Example #6
0
    def test_element_find_single_element(self):
        if is_ci():
            self.skipTest('Need to fix flaky test during running on CI')
        wait_for_element(self.driver, MobileBy.ANDROID_UIAUTOMATOR,
                         'new UiSelector().text("Accessibility")').click()
        wait_for_element(
            self.driver, MobileBy.ANDROID_UIAUTOMATOR,
            'new UiSelector().text("Accessibility Node Querying")').click()
        el = wait_for_element(self.driver, MobileBy.CLASS_NAME,
                              'android.widget.ListView')

        sub_el = el.find_element_by_accessibility_id('Task Take out Trash')
        self.assertIsNotNone(sub_el)
Example #7
0
    def test_find_based_on_image_template(self) -> None:
        image_path = desired_capabilities.PATH(
            'file/find_by_image_success.png')
        with open(image_path, 'rb') as png_file:
            b64_data = base64.b64encode(png_file.read()).decode('UTF-8')

        el = wait_for_element(self.driver, MobileBy.IMAGE, b64_data)
        size = el.size
        assert size['width'] is not None
        assert size['height'] is not None
        loc = el.location
        assert loc['x'] is not None
        assert loc['y'] is not None
        rect = el.rect
        assert rect['width'] is not None
        assert rect['height'] is not None
        assert rect['x'] is not None
        assert rect['y'] is not None
        assert el.is_displayed()
        el.click()
        wait_for_element(self.driver, MobileBy.ACCESSIBILITY_ID, "Alarm")
 def test_appium_service(self) -> None:
     assert self.service.is_running
     assert self.service.is_listening
     el = wait_for_element(self.driver, MobileBy.ACCESSIBILITY_ID,
                           'Accessibility')
     assert el is not None