当存高远 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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘