Git Product home page Git Product logo

sonic-uiautomator2-python-client's Introduction

🎉The Python Client of appium-uiautomator2-server

English | 简体中文

Background

At present, only one project appium-uiautomator2-client that bypasses Appium Server and interacts with appium-uiautomator2-server alone is seen on Github for Python, but it is not compatible The baseUrl of the latest appium-uiautomator2-server v5.x API has not been published on pypi. I tried to contact the author but there was no reply, so I decided to write a maintenance. For the Java version, you can see the sonic-driver-core maintained by our organization.

How to use

➡️More Document

  1. Install uiautomator2 server

You should install sonic-appium-uiautomator2-server.apk and sonic-appium-uiautomator2-server-test.apk in Here.

Alternatively, you can build your own Here

  1. Launch uiautomator2 server
adb shell am instrument -w io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner
  1. Forward ports
adb forward tcp:6790 tcp:6790
  1. Install Depends
pip install -U sonic-uia2-client
  1. Write your script
from common.models import AndroidSelector
from uia2.driver import AndroidDriver
import os


class TestDriver:

    def __init__(self):
        self.uia_url = "http://localhost:6790"
        self.adb_serial_num = "DAISKnlasido"
        self.package_name = "com.android.settings"

    def test_demo(self):
        # launch App
        os.system(
            "adb -s {} shell monkey -p {} -c android.intent.category.LAUNCHER 1".format(self.adb_serial_num,
                                                                                        self.package_name))
        
        # connect remote uia2 server
        driver = AndroidDriver(self.uia_url)
        p = driver.get_page_source()
        print(p)
        e = driver.find_element(AndroidSelector.XPATH, "//*[@text='设置']")
        if e is not None:
            print(e.get_text())
            e.send_keys("Hello")

Thanks

LICENSE

LICENSE

sonic-uiautomator2-python-client's People

Contributors

zhouyixun avatar upengfei avatar lihuacai168 avatar jg-li avatar mocobk 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.