Python+appium Learn to start the mobile browser

Source: Internet
Author: User
Tags python script appium

First, launch the browser:
The Python script in Pycharm is as follows:
From Appium import Webdriver

Desired_caps ={
' PlatformName ': ' Android ',
' DeviceName ': ' 127.0.0.1:62001 ',
' Platformversion ': ' 6.0 ',
' Apppackage ': ' Com.android.browser ',
' appactivity ': ' com.android.browser.BrowserActivity '
}
Webdriver. Remote (' Http://127.0.0.1:4723/wd/hub ', desired_caps)

Script Explanation:

PlatformName: Mobile phone system

DeviceName: You can use ADB devices in ADB to view

Platformversion: Android system version

Apppackage: You can use the ADB shell PM List Package command in ADB to view

Appactivity: In adb, use ADB logcat-c to clear the log, then use adb logcat activitymanager:i *:s, and then open the Laucheractivity software you want to view in the phone or simulator, When opened, the laucheractivity name of the software will be displayed.

Com.android.browser.BrowserActivity (You need to remove the diagonal bars inside the script)

Proceed to the following steps:

1, open the night God Simulator, in DOS first to connect the night God Simulator: Adb.exe connect 127.0.0.1:62001

ADB devices to see if the connection was successful;


2. Start Appium Service:

To set the default browser before starting Appium: Click the robot icon on the Appium and check the use Browser:browser
Start the Appium service: a triangle before starting, and a square after startup, such as:

3. Run the Python script

The browser on the night God Simulator will open automatically, and the desktop generates a unlock icon

The phone browser starts to complete:

Second, start the mobile app

The script is as follows: Modify apppackage and appactivity for the corresponding mobile app apppackage and appactivity

From Appium import Webdriver

Desired_caps ={
' PlatformName ': ' Android ',
' DeviceName ': ' 127.0.0.1:62001 ',
' Platformversion ': ' 6.0 ',
# ' apppackage ': ' Com.android.browser ',
# ' appactivity ': ' com.android.browser.BrowserActivity '
' Apppackage ': ' Com.hsd.huosuda_user ',
' appactivity ': ' com.hsd.huosuda_user.guide.WelcomeActivity '
}
Webdriver. Remote (' Http://127.0.0.1:4723/wd/hub ', desired_caps)

Proceed to the following steps:

1, open the night God Simulator, in DOS first to connect the night God Simulator: Adb.exe connect 127.0.0.1:62001

ADB devices to see if the connection was successful;

2. Start Appium Service:

To set application path before starting Appium: Click the robot icon on Appium, tick application path: Select the path of the APK, the content in the red box is the APK path that is selected manually, and the contents of the black box are automatically generated.

Start the Appium service: a triangle before starting, and a square after startup, such as:

3. Run the Python script

The mobile app on the night God Simulator will open automatically, while the desktop generates a unlock and appium setting icon

Mobile App Launch complete

Python+appium Learn to start the mobile browser

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.