当存高远 2019-11-30 21:10 采纳率: 50%
浏览 2350
已结题

python + Appium运行时,报错: A session is either terminated or not started 如何解决?

图片说明

代码如下:

from appium import webdriver
import time

#appium服务监听地址

server = 'http://localhost:4723/wd/hub' # localhost为本机;4723为端口(默认);/wd/hub可以看成是规定的默认地址

#app启动参数

desired_caps = {
"platformName": "Android", # platformName:使用哪个移动操作系统平台;iOS,Android或FirefoxOS
# "platformVersion":"5",
"deviceName": "127.0.0.1:62001", # deviceName:使用的移动设备或模拟器
"appPackage": "com.xcy.zj", # appPackage:填写包名
"appActivity": ".ui.activity.SplashActivity", # 要从包中启动的Android活动的活动名称
"newCommandTimeout" : 6000,
"unicodeKeyboard" : True,
"resetKeyboard" : True,
"noReset": True
}

#驱动

driver = webdriver.Remote(server, desired_caps)
driver.implicitly_wait(10)
##点击我的
driver.find_element_by_id("com.xcy.zj:id/act_main_my_text").click()

报错信息如下:

Traceback (most recent call last):
File "D:/ceshi/Pycharm/pycharm projects/init_/exercise/test20191130.py", line 19, in
driver.implicitly_wait(10)
File "D:\ceshi\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 912, in implicitly_wait
'implicit': int(float(time_to_wait) * 1000)})
File "D:\ceshi\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "D:\ceshi\Python\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
File "D:\ceshi\Python\lib\site-packages\appium\webdriver\errorhandler.py", line 24, in check_response
super(MobileErrorHandler, self).check_response(response)
File "D:\ceshi\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidSessionIdException: Message: A session is either terminated or not started

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-11-30 22:10
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大