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