Sitelet https://github.com/appium/python-client/commit/06fe1b5e558059c3608df9dcf3f66420e60952ee
Skip to content

Commit 06fe1b5

Browse files
authored
test: selendroid cleanup (#895)
* test: replace usage of selendroid app from 'test_install_app' in applications_tests.py * test: remove unused import pytest from applications_tests.py * test: fix broken TestContextSwitching by replacing selendroid with ApiDemos * test: remove selendroid-test-app.apk from apps folder
1 parent 5f11530 commit 06fe1b5

3 files changed

Lines changed: 25 additions & 12 deletions

File tree

‎test/apps/selendroid-test-app.apk‎

-202 KB
Binary file not shown.

‎test/functional/android/applications_tests.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import os
1717
from time import sleep
1818

19-
import pytest
20-
2119
from appium.webdriver.applicationstate import ApplicationState
2220

2321
from .helper.desired_capabilities import PATH
@@ -34,11 +32,11 @@ def test_is_app_installed(self) -> None:
3432
assert not self.driver.is_app_installed('sdfsdf')
3533
assert self.driver.is_app_installed(APIDEMO_PKG_NAME)
3634

37-
@pytest.mark.skip('This causes the server to crash. no idea why')
3835
def test_install_app(self) -> None:
39-
assert not self.driver.is_app_installed('io.selendroid.testapp')
40-
self.driver.install_app(PATH(os.path.join('../..', 'apps', 'selendroid-test-app.apk')))
41-
assert self.driver.is_app_installed('io.selendroid.testapp')
36+
self.driver.remove_app(APIDEMO_PKG_NAME)
37+
assert not self.driver.is_app_installed(APIDEMO_PKG_NAME)
38+
self.driver.install_app(PATH(os.path.join('../..', 'apps', 'ApiDemos-debug.apk.zip')))
39+
assert self.driver.is_app_installed(APIDEMO_PKG_NAME)
4240

4341
def test_remove_app(self) -> None:
4442
assert self.driver.is_app_installed(APIDEMO_PKG_NAME)

‎test/functional/android/context_switching_tests.py‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# limitations under the License.
1414

1515
import pytest
16+
from selenium.webdriver import ActionChains
17+
from selenium.webdriver.common.actions import interaction
18+
from selenium.webdriver.common.actions.action_builder import ActionBuilder
19+
from selenium.webdriver.common.actions.pointer_input import PointerInput
1620

1721
from appium import webdriver
1822
from appium.common.exceptions import NoSuchContextException
@@ -23,10 +27,9 @@
2327
from .helper import desired_capabilities
2428

2529

26-
@pytest.mark.skip(reason='Need to fix broken test')
2730
class TestContextSwitching(object):
2831
def setup_method(self) -> None:
29-
caps = desired_capabilities.get_desired_capabilities('selendroid-test-app.apk')
32+
caps = desired_capabilities.get_desired_capabilities('ApiDemos-debug.apk.zip')
3033
self.driver = webdriver.Remote(SERVER_URL_BASE, options=AppiumOptions().load_capabilities(caps))
3134

3235
def teardown_method(self) -> None:
@@ -39,12 +42,11 @@ def test_contexts_list(self) -> None:
3942

4043
def test_move_to_correct_context(self) -> None:
4144
self._enter_webview()
42-
assert 'WEBVIEW_io.selendroid.testapp' == self.driver.current_context
45+
assert 'WEBVIEW_io.appium.android.apis' == self.driver.current_context
4346

4447
def test_actually_in_webview(self) -> None:
4548
self._enter_webview()
46-
self.driver.find_element(by=AppiumBy.CSS_SELECTOR, value='input[type=submit]').click()
47-
el = self.driver.find_element(by=AppiumBy.XPATH, value='//h1[contains(., \'This is my way\')]')
49+
el = self.driver.find_element(by=AppiumBy.XPATH, value='//a[@id="i am a link"]')
4850
assert el is not None
4951

5052
def test_move_back_to_native_context(self) -> None:
@@ -57,6 +59,19 @@ def test_set_invalid_context(self) -> None:
5759
self.driver.switch_to.context('invalid name')
5860

5961
def _enter_webview(self) -> None:
60-
btn = self.driver.find_element(by=AppiumBy.NAME, value='buttonStartWebviewCD')
62+
btn = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Views')
6163
btn.click()
64+
self._scroll_to_webview()
65+
self._scroll_to_webview()
66+
btn_web_view = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='WebView')
67+
btn_web_view.click()
6268
self.driver.switch_to.context('WEBVIEW')
69+
70+
def _scroll_to_webview(self) -> None:
71+
actions = ActionChains(self.driver)
72+
actions.w3c_actions = ActionBuilder(self.driver, mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))
73+
actions.w3c_actions.pointer_action.move_to_location(393, 1915)
74+
actions.w3c_actions.pointer_action.pointer_down()
75+
actions.w3c_actions.pointer_action.move_to_location(462, 355)
76+
actions.w3c_actions.pointer_action.release()
77+
actions.perform()

0 commit comments

Comments
 (0)