Sitelet https://github.com/appium/python-client/pull/895/files
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed test/apps/selendroid-test-app.apk
Binary file not shown.
10 changes: 4 additions & 6 deletions test/functional/android/applications_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import os
from time import sleep

import pytest

from appium.webdriver.applicationstate import ApplicationState

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

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

def test_remove_app(self) -> None:
assert self.driver.is_app_installed(APIDEMO_PKG_NAME)
Expand Down
27 changes: 21 additions & 6 deletions test/functional/android/context_switching_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# limitations under the License.

import pytest
from selenium.webdriver import ActionChains
from selenium.webdriver.common.actions import interaction
from selenium.webdriver.common.actions.action_builder import ActionBuilder
from selenium.webdriver.common.actions.pointer_input import PointerInput

from appium import webdriver
from appium.common.exceptions import NoSuchContextException
Expand All @@ -23,10 +27,9 @@
from .helper import desired_capabilities


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

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

def test_move_to_correct_context(self) -> None:
self._enter_webview()
assert 'WEBVIEW_io.selendroid.testapp' == self.driver.current_context
assert 'WEBVIEW_io.appium.android.apis' == self.driver.current_context

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

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

def _enter_webview(self) -> None:
btn = self.driver.find_element(by=AppiumBy.NAME, value='buttonStartWebviewCD')
btn = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='Views')
btn.click()
self._scroll_to_webview()
self._scroll_to_webview()
btn_web_view = self.driver.find_element(by=AppiumBy.ACCESSIBILITY_ID, value='WebView')
btn_web_view.click()
self.driver.switch_to.context('WEBVIEW')

def _scroll_to_webview(self) -> None:
actions = ActionChains(self.driver)
actions.w3c_actions = ActionBuilder(self.driver, mouse=PointerInput(interaction.POINTER_TOUCH, "touch"))
actions.w3c_actions.pointer_action.move_to_location(393, 1915)
actions.w3c_actions.pointer_action.pointer_down()
actions.w3c_actions.pointer_action.move_to_location(462, 355)
actions.w3c_actions.pointer_action.release()
actions.perform()