diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fcb0e6626..db6516a60 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,122 @@ Changelog ========= +(unreleased) +------------ + +New +~~~ +- Feat: do not raise an error in case method is already defined (#632) + [Kazuaki Matsuo] +- Feat: add satellites in set_location (#620) [Kazuaki Matsuo] + + * feat: add satellites in set_location + + * fix review +- Feat: Add command with `setattr` (#615) [Kazuaki Matsuo] + + * chore: add placeholder + + * move to extention way + + * revert pytest + + * add todo + + * call method_name instead of wrapper + + * remove types + + * rename a method + + * add examples + + * add types-python-dateutil as error message + + * add example more + + * tweak naming + + * Explicit Dict +- Add types-python-dateutil in 4 branch. [Kazuaki Matsuo] +- Add test to check log path. [Kazuaki Matsuo] + +Fix +~~~ +- Fix tests. [Kazuaki Matsuo] +- Remove w3c argument in MobileWebElement (#598) [Kazuaki Matsuo] + + * Bump 2.0.0.b1 + + * Update changelog for 2.0.0.b1 + + * remove w3c +- Fix format with black. [Kazuaki Matsuo] +- Fix lint, CI and tests. [Kazuaki Matsuo] + +Other +~~~~~ +- Bump 2.0.0.rc4. [Kazuaki Matsuo] +- Tweak tests. [Kazuaki Matsuo] +- Remove w3c flag. [Kazuaki Matsuo] +- Remove w3c=True from MobileWebElement argument. [Kazuaki Matsuo] +- Bump selenium version. [Kazuaki Matsuo] +- Update changelog for 2.0.0.rc3. [Kazuaki Matsuo] +- Bump 2.0.0.rc3. [Kazuaki Matsuo] +- Use 4.0.0.rc3. [Kazuaki Matsuo] +- Update changelog for 2.0.0.rc2. [Kazuaki Matsuo] +- Bump 2.0.0.rc2. [Kazuaki Matsuo] +- Try rc2. [Kazuaki Matsuo] +- Update changelog for 2.0.0.rc1. [Kazuaki Matsuo] +- Bump 2.0.0.rc1. [Kazuaki Matsuo] +- Try rc1. [Kazuaki Matsuo] +- Update changelog for 2.0.0.b5. [Kazuaki Matsuo] +- Bump 2.0.0.b5. [Kazuaki Matsuo] +- Chore(deps): update pylint requirement from ~=2.8 to ~=2.10 (#628) + [dependabot[bot]] + + Updates the requirements on [pylint](https://github.com/PyCQA/pylint) to permit the latest version. + - [Release notes](https://github.com/PyCQA/pylint/releases) + - [Changelog](https://github.com/PyCQA/pylint/blob/main/ChangeLog) + - [Commits](https://github.com/PyCQA/pylint/compare/pylint-2.8.0...v2.10.2) + + --- + updated-dependencies: + - dependency-name: pylint + dependency-type: direct:production + ... +- Chore(deps): update tox requirement from ~=3.23 to ~=3.24 (#619) + [dependabot[bot]] + + Updates the requirements on [tox](https://github.com/tox-dev/tox) to permit the latest version. + - [Release notes](https://github.com/tox-dev/tox/releases) + - [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst) + - [Commits](https://github.com/tox-dev/tox/compare/3.23.0...3.24.0) + + --- + updated-dependencies: + - dependency-name: tox + dependency-type: direct:production + ... +- Override log. [Kazuaki Matsuo] +- Bump selenium version in tox. [Kazuaki Matsuo] +- Update changelog for 2.0.0.b4. [Kazuaki Matsuo] +- Bump 2.0.0.b4. [Kazuaki Matsuo] +- Use python selenium client v4.0.0.b4. [Kazuaki Matsuo] +- Update changelog for 2.0.0.b3. [Kazuaki Matsuo] +- Bump 2.0.0.b3. [Kazuaki Matsuo] +- Tweak some lines. [Kazuaki Matsuo] +- Update selenium in pipfile. [Kazuaki Matsuo] +- Bump selenium 4.0.0.b3. [Kazuaki Matsuo] +- Update pipfile. [Kazuaki Matsuo] +- Update changelog for 2.0.0.b2. [Kazuaki Matsuo] +- Bump 2.0.0.b2. [Kazuaki Matsuo] +- Bump base selenium version to 4.0.0.b2. [Kazuaki Matsuo] +- Bump v2.0.0.a0. [Kazuaki Matsuo] +- Update changelog for v2.0.0.a0. [Kazuaki Matsuo] +- Bump selenium. [Kazuaki Matsuo] + + v1.3.0 (2021-09-27) ------------------- diff --git a/Pipfile b/Pipfile index 24de9d00a..d4e0eda45 100644 --- a/Pipfile +++ b/Pipfile @@ -7,7 +7,7 @@ verify_ssl = true pre-commit = "~=2.15" [packages] -selenium = "~=3.141" +selenium = "~=4.0.0" black = "==20.8b1" diff --git a/README.md b/README.md index 0b2f8d1bd..fbfa9e869 100644 --- a/README.md +++ b/README.md @@ -7,18 +7,15 @@ [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -An extension library for adding [Selenium 3.0 draft](https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html) and [Mobile JSON Wire Protocol Specification draft](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md) -functionality to the Python language bindings, for use with the mobile testing -framework [Appium](https://appium.io). +An extension library for adding [WebDriver Protocol](https://www.w3.org/TR/webdriver/) and Appium commands to the Selenium Python language binding for use with the mobile testing framework [Appium](https://appium.io). ## Notice -Since **v1.0.0**, only Python 3 is supported +Since **v1.0.0**, only Python 3.7+ is supported. -### developing version -[selenium-4](https://github.com/appium/python-client/tree/selenium-4) branch is a developing branch to switch base selenium client version from v3 to v4. The branch is available as pre-release versioning like `2.0.0.a0` via pypi. - -Main differences since current v1 is the v2 can connect to invalid SSL environment like self-certificated server. Please take a look at the branch's README for more details. +Since **v2.0.0**, the base selenium client version is v4. +The version only works in W3C WebDriver protocol format. +If you would like to use the old protocol (MJSONWP), please use v1 Appium Python client. ## Getting the Appium Python client @@ -52,12 +49,8 @@ download and unarchive the source tarball (Appium-Python-Client-X.X.tar.gz). ## Usage -The Appium Python Client is fully compliant with the Selenium 3.0 specification -draft, with some helpers to make mobile testing in Python easier. The majority of -the usage remains as it has been for Selenium 2 (WebDriver), and as the [official -Selenium Python bindings](https://pypi.org/project/selenium/) begins to -implement the new specification that implementation will be used underneath, so -test code can be written that is utilizable with both bindings. +The Appium Python Client is fully compliant with the WebDriver Protocol +including several helpers to make mobile testing in Python easier. To use the new functionality now, and to use the superset of functions, instead of including the Selenium `webdriver` module in your test code, use that from @@ -133,6 +126,25 @@ desired_caps = dict( self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps, direct_connection=True) ``` +## Relax SSL validation + +`strict_ssl` option allows you to send commands to an invalid certificate host like a self-signed one. + +```python +import unittest +from appium import webdriver + +desired_caps = dict( + platformName='iOS', + platformVersion='13.4', + automationName='xcuitest', + deviceName='iPhone Simulator', + app=PATH('../../apps/UICatalog.app.zip') +) + +self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps, strict_ssl=False) +``` + ## Documentation - https://appium.github.io/python-client-sphinx/ is detailed documentation diff --git a/appium/version.py b/appium/version.py index dc59fbaf3..9dd833aa4 100644 --- a/appium/version.py +++ b/appium/version.py @@ -1 +1 @@ -version = '1.3.0' +version = '2.0.0.rc4' diff --git a/appium/webdriver/appium_connection.py b/appium/webdriver/appium_connection.py index 36fa34327..eb218b994 100644 --- a/appium/webdriver/appium_connection.py +++ b/appium/webdriver/appium_connection.py @@ -13,8 +13,9 @@ # limitations under the License. import uuid -from typing import TYPE_CHECKING, Any, Dict +from typing import TYPE_CHECKING, Any, Dict, Union +import urllib3 from selenium.webdriver.remote.remote_connection import RemoteConnection from appium.common.helper import library_version @@ -24,6 +25,23 @@ class AppiumConnection(RemoteConnection): + def _get_connection_manager(self) -> Union[urllib3.PoolManager, urllib3.ProxyManager]: + # https://github.com/SeleniumHQ/selenium/blob/0e0194b0e52a34e7df4b841f1ed74506beea5c3e/py/selenium/webdriver/remote/remote_connection.py#L134 + pool_manager_init_args = {'timeout': self._timeout} + # pylint: disable=E1101 + if self._ca_certs: + pool_manager_init_args['cert_reqs'] = 'CERT_REQUIRED' + pool_manager_init_args['ca_certs'] = self._ca_certs + else: + # This line is necessary to disable certificate verification + pool_manager_init_args['cert_reqs'] = 'CERT_NONE' + + return ( + urllib3.PoolManager(**pool_manager_init_args) + if self._proxy_url is None + else urllib3.ProxyManager(self._proxy_url, **pool_manager_init_args) + ) + @classmethod def get_remote_connection_headers(cls, parsed_url: 'ParseResult', keep_alive: bool = True) -> Dict[str, Any]: """Override get_remote_connection_headers in RemoteConnection""" diff --git a/appium/webdriver/extensions/action_helpers.py b/appium/webdriver/extensions/action_helpers.py index 0a0fc4c25..dcb38e6d2 100644 --- a/appium/webdriver/extensions/action_helpers.py +++ b/appium/webdriver/extensions/action_helpers.py @@ -45,7 +45,7 @@ def scroll(self: T, origin_el: WebElement, destination_el: WebElement, duration: """ # XCUITest x W3C spec has no duration by default in server side - if self.w3c and duration is None: + if duration is None: duration = 600 action = TouchAction(self) diff --git a/appium/webdriver/mobilecommand.py b/appium/webdriver/mobilecommand.py index b0bd8c4d5..966d7e4c1 100644 --- a/appium/webdriver/mobilecommand.py +++ b/appium/webdriver/mobilecommand.py @@ -107,3 +107,7 @@ class MobileCommand: # iOS TOUCH_ID = 'touchId' TOGGLE_TOUCH_ID_ENROLLMENT = 'toggleTouchIdEnrollment' + + # To override selenium commands + GET_LOG = 'getLog' + GET_AVAILABLE_LOG_TYPES = 'getAvailableLogTypes' diff --git a/appium/webdriver/webdriver.py b/appium/webdriver/webdriver.py index 5712cf86a..ab5998ae5 100644 --- a/appium/webdriver/webdriver.py +++ b/appium/webdriver/webdriver.py @@ -78,7 +78,6 @@ _OSS_W3C_CONVERSION = {'acceptSslCerts': 'acceptInsecureCerts', 'version': 'browserVersion', 'platform': 'platformName'} _EXTENSION_CAPABILITY = ':' -_FORCE_MJSONWP = 'forceMjsonwp' # override # Add appium prefix for the non-W3C capabilities @@ -262,8 +261,16 @@ def __init__( keep_alive: bool = True, direct_connection: bool = False, extensions: List[T] = [], + strict_ssl: bool = True, ): + if strict_ssl is False: + # pylint: disable=E1101 + import urllib3 + + AppiumConnection.set_certificate_bundle_path(None) + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + super().__init__( AppiumConnection(command_executor, keep_alive=keep_alive), desired_capabilities, browser_profile, proxy ) @@ -314,17 +321,17 @@ def _update_command_executor(self, keep_alive: bool) -> None: direct_port = 'directConnectPort' direct_path = 'directConnectPath' - if not {direct_protocol, direct_host, direct_port, direct_path}.issubset(set(self.capabilities)): + if not {direct_protocol, direct_host, direct_port, direct_path}.issubset(set(self.caps)): message = 'Direct connect capabilities from server were:\n' for key in [direct_protocol, direct_host, direct_port, direct_path]: - message += '{}: \'{}\'\n'.format(key, self.capabilities.get(key, '')) + message += '{}: \'{}\'\n'.format(key, self.caps.get(key, '')) logger.warning(message) return - protocol = self.capabilities[direct_protocol] - hostname = self.capabilities[direct_host] - port = self.capabilities[direct_port] - path = self.capabilities[direct_path] + protocol = self.caps[direct_protocol] + hostname = self.caps[direct_host] + port = self.caps[direct_port] + path = self.caps[direct_path] executor = f'{protocol}://{hostname}:{port}{path}' logger.info('Updated request endpoint to %s', executor) @@ -332,6 +339,7 @@ def _update_command_executor(self, keep_alive: bool) -> None: self.command_executor = RemoteConnection(executor, keep_alive=keep_alive) self._addCommands() + # https://github.com/SeleniumHQ/selenium/blob/06fdf2966df6bca47c0ae45e8201cd30db9b9a49/py/selenium/webdriver/remote/webdriver.py#L277 def start_session(self, capabilities: Dict, browser_profile: Optional[str] = None) -> None: """Creates a new session with the desired capabilities. @@ -358,30 +366,18 @@ def start_session(self, capabilities: Dict, browser_profile: Optional[str] = Non if 'sessionId' not in response: response = response['value'] self.session_id = response['sessionId'] - self.capabilities = response.get('value') + self.caps = response.get('value') # if capabilities is none we are probably speaking to # a W3C endpoint - if self.capabilities is None: - self.capabilities = response.get('capabilities') + if self.caps is None: + self.caps = response.get('capabilities') # Double check to see if we have a W3C Compliant browser - self.w3c = response.get('status') is None - self.command_executor.w3c = self.w3c + self.command_executor.w3c = True def _merge_capabilities(self, capabilities: Dict) -> Dict[str, Any]: """Manage capabilities whether W3C format or MJSONWP format""" - if _FORCE_MJSONWP in capabilities: - logger.warning( - "[Deprecated] 'forceMjsonwp' capability will be dropped after switching base selenium client from v3 to v4 " - "to follow W3C spec capabilities. Appium 2.0 will also support only W3C session creation capabilities." - ) - force_mjsonwp = capabilities[_FORCE_MJSONWP] - del capabilities[_FORCE_MJSONWP] - - if force_mjsonwp != False: - return {'desiredCapabilities': capabilities} - w3c_caps = _make_w3c_caps(capabilities) return {'capabilities': w3c_caps, 'desiredCapabilities': capabilities} @@ -398,18 +394,17 @@ def find_element(self, by: str = By.ID, value: Union[str, Dict] = None) -> Mobil """ # TODO: If we need, we should enable below converter for Web context - # if self.w3c: - # if by == By.ID: - # by = By.CSS_SELECTOR - # value = '[id="%s"]' % value - # elif by == By.TAG_NAME: - # by = By.CSS_SELECTOR - # elif by == By.CLASS_NAME: - # by = By.CSS_SELECTOR - # value = ".%s" % value - # elif by == By.NAME: - # by = By.CSS_SELECTOR - # value = '[name="%s"]' % value + # if by == By.ID: + # by = By.CSS_SELECTOR + # value = '[id="%s"]' % value + # elif by == By.TAG_NAME: + # by = By.CSS_SELECTOR + # elif by == By.CLASS_NAME: + # by = By.CSS_SELECTOR + # value = ".%s" % value + # elif by == By.NAME: + # by = By.CSS_SELECTOR + # value = '[name="%s"]' % value return self.execute(RemoteCommand.FIND_ELEMENT, {'using': by, 'value': value})['value'] @@ -425,25 +420,24 @@ def find_elements(self, by: str = By.ID, value: Union[str, Dict] = None) -> Unio :obj:`list` of :obj:`appium.webdriver.webelement.WebElement`: The found elements """ # TODO: If we need, we should enable below converter for Web context - # if self.w3c: - # if by == By.ID: - # by = By.CSS_SELECTOR - # value = '[id="%s"]' % value - # elif by == By.TAG_NAME: - # by = By.CSS_SELECTOR - # elif by == By.CLASS_NAME: - # by = By.CSS_SELECTOR - # value = ".%s" % value - # elif by == By.NAME: - # by = By.CSS_SELECTOR - # value = '[name="%s"]' % value + # if by == By.ID: + # by = By.CSS_SELECTOR + # value = '[id="%s"]' % value + # elif by == By.TAG_NAME: + # by = By.CSS_SELECTOR + # elif by == By.CLASS_NAME: + # by = By.CSS_SELECTOR + # value = ".%s" % value + # elif by == By.NAME: + # by = By.CSS_SELECTOR + # value = '[name="%s"]' % value # Return empty list if driver returns null # See https://github.com/SeleniumHQ/selenium/issues/4555 return self.execute(RemoteCommand.FIND_ELEMENTS, {'using': by, 'value': value})['value'] or [] - def create_web_element(self, element_id: Union[int, str], w3c: bool = False) -> MobileWebElement: + def create_web_element(self, element_id: Union[int, str]) -> MobileWebElement: """Creates a web element with the specified element_id. Overrides method in Selenium WebDriver in order to always give them @@ -451,12 +445,11 @@ def create_web_element(self, element_id: Union[int, str], w3c: bool = False) -> Args: element_id: The element id to create a web element - w3c: Whether the element is W3C or MJSONWP Returns: `MobileWebElement` """ - return MobileWebElement(self, element_id, w3c) + return MobileWebElement(self, element_id) def set_value(self, element: MobileWebElement, value: str) -> T: """Set the value on an element in the application. @@ -515,3 +508,8 @@ def _addCommands(self) -> None: 'GET', '/session/$sessionId/element/$id/location_in_view', ) + + # override for Appium 1.x + # Appium 2.0 and Appium 1.22 work with `/se/log` and `/se/log/types` + self.command_executor._commands[Command.GET_LOG] = ('POST', '/session/$sessionId/log') + self.command_executor._commands[Command.GET_AVAILABLE_LOG_TYPES] = ('GET', '/session/$sessionId/log/types') diff --git a/ci-jobs/functional/run_appium.yml b/ci-jobs/functional/run_appium.yml index 333449d7e..a866957c4 100644 --- a/ci-jobs/functional/run_appium.yml +++ b/ci-jobs/functional/run_appium.yml @@ -13,6 +13,8 @@ steps: versionSpec: '3.x' - script: brew install ffmpeg displayName: Resolve dependencies (Appium server) +# - script: pip install trio==0.17.0 +# displayName: Install trio - script: python setup.py install displayName: Install python language bindings for Appium - script: | diff --git a/setup.py b/setup.py index a8c8867cb..7eb4e8bc2 100644 --- a/setup.py +++ b/setup.py @@ -47,5 +47,5 @@ 'Topic :: Software Development :: Quality Assurance', 'Topic :: Software Development :: Testing', ], - install_requires=['selenium >= 3.14.1, < 4'], + install_requires=['selenium ~= 4.0.0'], ) diff --git a/test/functional/android/helper/test_helper.py b/test/functional/android/helper/test_helper.py index 25f14ce2c..1f726f55e 100644 --- a/test/functional/android/helper/test_helper.py +++ b/test/functional/android/helper/test_helper.py @@ -22,6 +22,13 @@ from . import desired_capabilities +if TYPE_CHECKING: + from appium.webdriver.webdriver import WebDriver + from appium.webdriver.webelement import WebElement + +# the emulator is sometimes slow and needs time to think +SLEEPY_TIME = 10 + # The package name of ApiDemos-debug.apk.zip APIDEMO_PKG_NAME = 'io.appium.android.apis' diff --git a/test/functional/ios/safari_tests.py b/test/functional/ios/safari_tests.py index 4c25920e8..a62cf2852 100644 --- a/test/functional/ios/safari_tests.py +++ b/test/functional/ios/safari_tests.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import time + from appium import webdriver from .helper.desired_capabilities import get_desired_capabilities @@ -34,4 +36,9 @@ def test_context(self) -> None: def test_get(self) -> None: self.driver.get("http://google.com") - assert 'Google' == self.driver.title + for _ in range(5): + time.sleep(0.5) + if 'Google' == self.driver.title: + return + + assert False, 'The title was wrong' diff --git a/test/unit/webdriver/log_test.py b/test/unit/webdriver/log_test.py new file mode 100644 index 000000000..3c63f657c --- /dev/null +++ b/test/unit/webdriver/log_test.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json + +import httpretty + +from appium.webdriver.webdriver import WebDriver +from test.unit.helper.test_helper import appium_command, get_httpretty_request_body, ios_w3c_driver + + +class TestWebDriverLog(object): + @httpretty.activate + def test_get_log_types(self): + driver = ios_w3c_driver() + httpretty.register_uri( + httpretty.GET, + appium_command('/session/1234567890/log/types'), + body=json.dumps({'value': ['syslog']}), + ) + log_types = driver.log_types + assert log_types == ['syslog'] + + @httpretty.activate + def test_get_log(self): + driver = ios_w3c_driver() + httpretty.register_uri( + httpretty.POST, + appium_command('/session/1234567890/log'), + body=json.dumps({'value': ['logs as array']}), + ) + log_types = driver.get_log('syslog') + assert log_types == ['logs as array'] + + d = get_httpretty_request_body(httpretty.last_request()) + assert {'type': 'syslog'} == d diff --git a/test/unit/webdriver/search_context/android_test.py b/test/unit/webdriver/search_context/android_test.py index badee09f6..94aefe081 100644 --- a/test/unit/webdriver/search_context/android_test.py +++ b/test/unit/webdriver/search_context/android_test.py @@ -73,7 +73,7 @@ def test_find_elements_by_android_data_matcher_no_value(self): @httpretty.activate def test_find_element_by_android_data_matcher(self): driver = android_w3c_driver() - element = MobileWebElement(driver, 'element_id', w3c=True) + element = MobileWebElement(driver, 'element_id') httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/element/element_id/element'), @@ -94,7 +94,7 @@ def test_find_element_by_android_data_matcher(self): @httpretty.activate def test_find_elements_by_android_data_matcher(self): driver = android_w3c_driver() - element = MobileWebElement(driver, 'element_id', w3c=True) + element = MobileWebElement(driver, 'element_id') httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/element/element_id/elements'), @@ -113,7 +113,7 @@ def test_find_elements_by_android_data_matcher(self): @httpretty.activate def test_find_elements_by_android_data_matcher_no_value(self): driver = android_w3c_driver() - element = MobileWebElement(driver, 'element_id', w3c=True) + element = MobileWebElement(driver, 'element_id') httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/element/element_id/elements'), body='{"value": []}' ) diff --git a/test/unit/webdriver/search_context/windows_test.py b/test/unit/webdriver/search_context/windows_test.py index 5e0b3c4a6..99296df18 100644 --- a/test/unit/webdriver/search_context/windows_test.py +++ b/test/unit/webdriver/search_context/windows_test.py @@ -22,7 +22,7 @@ class TestWebDriverWindowsSearchContext(object): @httpretty.activate def test_find_element_by_windows_uiautomation(self): driver = android_w3c_driver() - element = MobileWebElement(driver, 'element_id', w3c=True) + element = MobileWebElement(driver, 'element_id') httpretty.register_uri( httpretty.POST, appium_command('/session/1234567890/element/element_id/element'), diff --git a/test/unit/webdriver/webdriver_test.py b/test/unit/webdriver/webdriver_test.py index d9cfea29b..db0281a10 100644 --- a/test/unit/webdriver/webdriver_test.py +++ b/test/unit/webdriver/webdriver_test.py @@ -61,42 +61,8 @@ def test_create_session(self): assert request_json.get('desiredCapabilities') is not None assert driver.session_id == 'session-id' - assert driver.w3c assert driver.command_executor.w3c - @httpretty.activate - def test_create_session_forceMjsonwp(self): - httpretty.register_uri( - httpretty.POST, - 'http://localhost:4723/wd/hub/session', - body='{ "capabilities": {"deviceName": "Android Emulator"}, "status": 0, "sessionId": "session-id"}', - ) - - desired_caps = { - 'platformName': 'Android', - 'deviceName': 'Android Emulator', - 'app': 'path/to/app', - 'automationName': 'UIAutomator2', - 'forceMjsonwp': True, - } - driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) - - # This tests counts the same request twice on Azure only for now (around 20th May, 2021). Local running works. - # Should investigate the cause. - # assert len(httpretty.HTTPretty.latest_requests) == 1 - - request = httpretty.HTTPretty.latest_requests[0] - assert request.headers['content-type'] == 'application/json;charset=UTF-8' - assert 'appium/python {} (selenium'.format(appium_version.version) in request.headers['user-agent'] - - request_json = json.loads(httpretty.HTTPretty.latest_requests[0].body.decode('utf-8')) - assert request_json.get('capabilities') is None - assert request_json.get('desiredCapabilities') is not None - - assert driver.session_id == 'session-id' - assert driver.w3c is False - assert driver.command_executor.w3c is False - @httpretty.activate def test_create_session_change_session_id(self): httpretty.register_uri( @@ -255,7 +221,6 @@ def exceptionCallback(request, uri, headers): driver = ios_w3c_driver() httpretty.register_uri(httpretty.GET, appium_command('/session/1234567890'), body=exceptionCallback) events = driver.events - mock_warning.assert_called_once() assert events == {} @httpretty.activate diff --git a/test/unit/webdriver/webelement_test.py b/test/unit/webdriver/webelement_test.py index f9b38922a..59464fd89 100644 --- a/test/unit/webdriver/webelement_test.py +++ b/test/unit/webdriver/webelement_test.py @@ -28,7 +28,7 @@ def test_set_value(self): driver = android_w3c_driver() httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/appium/element/element_id/value')) - element = MobileWebElement(driver, 'element_id', w3c=True) + element = MobileWebElement(driver, 'element_id') value = 'happy testing' element.set_value(value) @@ -40,7 +40,7 @@ def test_send_key(self): driver = android_w3c_driver() httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/element/element_id/value')) - element = MobileWebElement(driver, 'element_id', w3c=True) + element = MobileWebElement(driver, 'element_id') element.send_keys('happy testing') d = get_httpretty_request_body(httpretty.last_request()) @@ -54,7 +54,7 @@ def test_send_key_with_file(self): httpretty.register_uri(httpretty.POST, appium_command('/session/1234567890/element/element_id/value')) try: - element = MobileWebElement(driver, 'element_id', w3c=True) + element = MobileWebElement(driver, 'element_id') element.send_keys(tmp_f.name) finally: tmp_f.close() @@ -72,7 +72,7 @@ def test_get_attribute_with_dict(self): body=json.dumps({"value": rect_dict}), ) - element = MobileWebElement(driver, 'element_id', w3c=True) + element = MobileWebElement(driver, 'element_id') ef = element.get_attribute('rect') d = httpretty.last_request()