Coder Social home page Coder Social logo

python-client's Introduction

Appium Python Client

PyPI version Downloads

Build Status

Code style: black

An extension library for adding Selenium 3.0 draft and Mobile JSON Wire Protocol Specification draft functionality to the Python language bindings, for use with the mobile testing framework Appium.

Notice

Since v1.0.0, only Python 3 is supported

developing version

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.

Getting the Appium Python client

There are three ways to install and use the Appium Python client.

  1. Install from PyPi, as 'Appium-Python-Client'.

    pip install Appium-Python-Client

    You can see the history from here

  2. Install from source, via PyPi. From 'Appium-Python-Client', download and unarchive the source tarball (Appium-Python-Client-X.X.tar.gz).

    tar -xvf Appium-Python-Client-X.X.tar.gz
    cd Appium-Python-Client-X.X
    python setup.py install
  3. Install from source via GitHub.

    git clone [email protected]:appium/python-client.git
    cd python-client
    python setup.py install

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 begins to implement the new specification that implementation will be used underneath, so test code can be written that is utilizable with both bindings.

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 Appium instead.

from appium import webdriver

From there much of your test code will work with no change.

As a base for the following code examples, the following sets up the UnitTest environment:

# Android environment
import unittest
from appium import webdriver

desired_caps = dict(
    platformName='Android',
    platformVersion='10',
    automationName='uiautomator2',
    deviceName='Android Emulator',
    app=PATH('../../../apps/selendroid-test-app.apk')
)
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
el = self.driver.find_element_by_accessibility_id('item')
el.click()
# iOS environment
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)
el = self.driver.find_element_by_accessibility_id('item')
el.click()

Direct Connect URLs

If your Selenium/Appium server decorates the new session capabilities response with the following keys:

  • directConnectProtocol
  • directConnectHost
  • directConnectPort
  • directConnectPath

Then python client will switch its endpoint to the one specified by the values of those keys.

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, direct_connection=True)

Documentation

https://appium.github.io/python-client-sphinx/ is detailed documentation

Development

  • Code Style: PEP-0008
    • Apply black, isort and mypy as pre commit hook
    • Run make command for development. See make help output for details
  • Docstring style: Google Style
  • gitchangelog generates CHANGELOG.rst

Setup

  • pip install --user pipenv
  • python -m pipenv lock --clear
    • If you experience Locking Failed! unknown locale: UTF-8 error, then refer pypa/pipenv#187 to solve it.
  • python -m pipenv install --dev --system
  • pre-commit install

Run tests

You can run all of tests running on CI via tox in your local.

$ tox

You also can run particular tests like below.

Unit

$ pytest test/unit

Run with pytest-xdist

$ pytest -n 2 test/unit

Functional

$ pytest test/functional/ios/search_context/find_by_ios_class_chain_tests.py

In parallel for iOS

  1. Create simulators named 'iPhone 8 - 8100' and 'iPhone 8 - 8101'
  2. Install test libraries via pip, pip install pytest pytest-xdist
  3. Run tests
$ pytest -n 2 test/functional/ios/search_context/find_by_ios_class_chain_tests.py

Release

Follow below steps.

$ pip install twine
$ pip install git+git://github.com/vaab/gitchangelog.git # Getting via GitHub repository is necessary for Python 3.7
# Type the new version number and 'yes' if you can publish it
# You can test the command with DRY_RUN
$ DRY_RUN=1 ./release.sh
$ ./release.sh # release

License

Apache License v2

python-client's People

Contributors

kazucocoa avatar imurchie avatar ki4070ma avatar jlipps avatar manoj9788 avatar mykola-mokhnach avatar dependabot[bot] avatar dependabot-preview[bot] avatar jonahss avatar dpgraham avatar bayandin avatar bootstraponline avatar rajeshkumarayyadurai avatar wkplus avatar urtow avatar benzhou29 avatar venkateshps avatar tadashi0713 avatar iamnrupesh avatar emil-petersen avatar salehbigdeli avatar bassoon08 avatar madh93 avatar mmartin313 avatar nichotined avatar pr4bh4sh avatar srinivasantarget avatar akulavenkatesh avatar ianxiaohanxu avatar joshuasince1986 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.