def test_drag_and_drop_ios(self): mock_desk = MagicMock() mock_desk._get_platform = MagicMock(return_value='ios') webdriver.Remote = WebdriverRemoteMock TouchAction.move_to = MagicMock() TouchAction.release = MagicMock() MobileLibrary.open_application(mock_desk, 'remote_url') MobileLibrary.drag_and_drop(mock_desk, "some_locator", "some_other_locator") mock_desk._platform_dependant_press.assert_called() TouchAction.move_to.assert_called_with(unittest.mock.ANY) TouchAction.release.assert_called()
def test_drag_and_drop_with_offset(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock TouchAction.move_to = MagicMock() TouchAction.release = MagicMock() MobileLibrary.open_application(mock_desk, 'remote_url') MobileLibrary.drag_and_drop_by_offset(mock_desk, "some_locator", x_offset=100, y_offset=100) mock_desk._platform_dependant_press.assert_called() TouchAction.move_to.assert_called_with(x=unittest.mock.ANY, y=unittest.mock.ANY) TouchAction.release.assert_called()
def test_is_text_visible(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock mock_desk._element_find_by_text().is_displayed = MagicMock( return_value=True) result = MobileLibrary._is_text_visible(mock_desk, "some_text") self.assertTrue(result)
def test_scroll_to_text_android_scroll(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock mock_desk._is_android = MagicMock(return_value=True) mock_desk._is_ios = MagicMock(return_value=False) mock_desk._is_text_present = MagicMock(side_effect=[False, True]) result = MobileLibrary._scroll_to_text(mock_desk, "some_text", "down") self.assertTrue(result)
def test_scroll_to_text_android_visible_no_scroll(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock mock_desk._is_ios = MagicMock(return_value=False) mock_desk._is_android = MagicMock(return_value=True) mock_desk._is_text_present = MagicMock(return_value=True) result = MobileLibrary._scroll_to_text(mock_desk, "some_text", "up") self.assertTrue(result)
def test_wait_for_and_click_text_exact(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock MobileLibrary.open_application(mock_desk, 'remote_url') MobileLibrary.wait_for_and_click_text(mock_desk, "some_text", True) mock_desk.click_text.assert_called_with("some_text", True)
def test_wait_until_page_contains_element_private(self): mock_desk = MagicMock() MobileLibrary._wait_until_page_contains_element( mock_desk, 'some_element', 5) mock_desk._wait_until.asser_called_with('some_element', 5)
def test_save_appium_screenshot(self): mock_desk = MagicMock() MobileLibrary.save_appium_screenshot(mock_desk) mock_desk.capture_page_screenshot.assert_called()
def test_capture_page_screenshot(self): mock_desk = MagicMock() mock_desk._get_screenshot_paths = MagicMock( return_value=['path', 'link']) MobileLibrary.capture_page_screenshot(mock_desk) mock_desk._get_screenshot_paths.assert_called()
def test_wait_for_and_tap_multiple(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock MobileLibrary.open_application(mock_desk, 'remote_url') MobileLibrary.wait_for_and_tap(mock_desk, "some_locator", count=4) mock_desk.tap.assert_called_with("some_locator", None, None, 4)
def test_wait_for_and_input_text_simple(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock MobileLibrary.open_application(mock_desk, 'remote_url') MobileLibrary.wait_for_and_clear_text(mock_desk, "some_locator") mock_desk.clear_text.assert_called_with("some_locator")
def test_import_defaults(self): MobileLibrary()
def test_wait_until_element_is_disabled(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock MobileLibrary.open_application(mock_desk, 'remote_url') MobileLibrary.wait_until_element_is_disabled(mock_desk, "some_locator") mock_desk.element_should_be_disabled.assert_called_with("some_locator")
def test_is_text_visible_not_found(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock mock_desk._element_find_by_text = MagicMock(return_value=None) result = MobileLibrary._is_text_visible(mock_desk, "some_text") self.assertIsNone(result)
def test_platform_dependant_press_ios_private(self): mock_desk = MagicMock() mock_desk._is_ios = MagicMock(return_value=True) MobileLibrary._platform_dependant_press(mock_desk, MagicMock(), 'some_element')
def test_wait_for_and_click_button(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock MobileLibrary.open_application(mock_desk, 'remote_url') MobileLibrary.wait_for_and_click_button(mock_desk, "some_button") mock_desk.click_button.assert_called_with("some_button")
def test_wait_for_and_long_press(self): mock_desk = MagicMock() webdriver.Remote = WebdriverRemoteMock MobileLibrary.open_application(mock_desk, 'remote_url') MobileLibrary.wait_for_and_long_press(mock_desk, "some_locator", 1000) mock_desk.long_press.assert_called_with("some_locator", 1000)
def test_import_overrides(self): MobileLibrary(timeout=10, run_on_failure='Capture Page Screenshot')