問題:
運行python代碼,遇到問題:selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: platformName, deviceName)
解決方法
前置條件:我是使用的appium Server命令行安裝
步驟1:卸載appium 運行-cmd 輸入命令:npm uninstall -g appium
步驟2:指定appium版本安裝appium, 運行-cmd -輸入命令:>
npm install appium@1.17.1 -g --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver
代碼:
"""
@Time ?:2023/12/1911:11
@Auth ?:
@File ?:testA1.py
"""
from appium import webdriver
from time import sleep
# server啟動參數(shù)
# Caps = {
# ????#設(shè)備信息
# ????"platformName": "Android",#使用手機的操作系統(tǒng)
# ????"platformVersion": "test",#手機操作系統(tǒng)的版本
# ????"deviceName": "re",#使用手機或模擬器類型
# ????#App信息
# ????"app": "tes " #本地絕對路徑或http url所指向的一個安裝包,注意如果指定了appPackage和appActivity,該參數(shù)就不需要
# }
# 查找報名:Aapt dump badging 路徑(D:)
caps = {}
caps["platformName"] = "Android" ?# 使用手機的操作系統(tǒng)
caps["platformVersion"] = "7.1.2" ?# 手機操作系統(tǒng)的版本
caps["deviceName"] = "127.0.0.1:62001" ?# 使用手機或模擬器類型
# caps["app"]=r"E:\appapk\9ikandianv3.35.4_downcc.com.apk"
caps["appPackage"] = "com.android.settings" ?# 包名
caps["appActivity"] = ".Settings"
# caps["appPackage"] = "com.zhiguan.m9ikandian" ?# 添加包名
# caps["appActivity"] = "com.zhiguan.m9ikandian.component.activity.SplashActivity" ?# Activity這里就是一個網(wǎng)站的首頁
# 運行代碼前啟動appium,命令行啟動或工具啟動
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps) ?#
# driver 的第一個參數(shù)wd/hub是連接遠程路徑,這個是固定的。
sleep(5)文章來源:http://www.zghlxwxcb.cn/news/detail-766340.html
已解決:連接模擬器正常。文章來源地址http://www.zghlxwxcb.cn/news/detail-766340.html
到了這里,關(guān)于連接安卓模擬器報錯,selenium.common.exceptions.SessionNotCreatedException: Message: A new session could not已解決的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!