参考文档:https://blog.csdn.net/u013314786/article/details/83216390
接上文:
安装完成后要进行一下简单修改:
(1)、打开安装目录,进入到bin目录(比如:D:\Nox\bin)
(2)、把安装好的Android SDK里的adb.exe文件(比如我的在D:\Android\SDK\platform-tools目录下)复制到该目录覆盖掉该目录已存在的adb.exe文件
(3)、删掉该目录的nox_adb.exe文件,再复制一份adb.exe并重命名为nox_adb.exe
(4)、启动模拟器
===========================================================================
确认夜神模拟器是否启动成功:
================================================================================
启动python,执行脚本
# adb shell dumpsys window w |findstr \/ |findstr name= # from appium import webdriver import time desired_caps = { 'platformName': 'Android', 'deviceName':'127.0.0.1:62001', 'platformVersion': '5.1.1', 'appPackage': 'com.youdao.calculator', 'appActivity': 'com.youdao.calculator.activities.MainActivity', 'automationName':'UiAutomator1', } driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps) time.sleep(5) #driver.find_element_by_id('com.youdao.calculator:id/guide_button').click() print(driver.current_package) print('-------------------------') print(driver.current_activity) print('-------------------------') print(driver.capabilities) time.sleep(5) driver.quit()
执行结果:
com.youdao.calculator
-------------------------
.activities.GuideActivity
-------------------------
{'platform': 'LINUX', 'webStorageEnabled': False, 'takesScreenshot': True, 'javascriptEnabled': True, 'databaseEnabled': False, 'networkConnectionEnabled': True, 'locationContextEnabled': False, 'warnings': {},
'desired': {
'platformName': 'Android',
'deviceName': '127.0.0.1:62001',
'platformVersion': '5.1.1',
'appPackage': 'com.youdao.calculator',
'appActivity': 'com.youdao.calculator.activities.MainActivity',
'automationName': 'UiAutomator1'
}, 'platformName': 'Android', 'deviceName': '127.0.0.1:62001', 'platformVersion': '5.1.1', 'appPackage': 'com.youdao.calculator', 'appActivity': 'com.youdao.calculator.activities.MainActivity', 'automationName': 'UiAutomator1', 'deviceUDID': '127.0.0.1:62001', 'deviceScreenSize': '720x1280', 'deviceModel': 'MI 9', 'deviceManufacturer': 'Xiaomi'}
======================================================================================================