老师,启动了seleniumserver stand online,还是报错

来源:3-12 requests实现打开地址封装

慕粉1212355798

2021-01-17

#coding=utf-8
import requests
import json
url = 'http://127.0.0.1:4444/wd/hub/session/'
data = json.dumps({
‘desiredCapabilities’:{
‘browserName’:‘chrome’
}
})
res = requests.post(url, data).json()
session = res[‘sessionId’]
print(session)

控制台报错:
D:\练习python\seleniumpythonbase\venv\Scripts\python.exe D:/练习python/seleniumpythonbase/ThreeNode/requests_open_browser.py
Traceback (most recent call last):
File “D:/练习python/seleniumpythonbase/ThreeNode/requests_open_browser.py”, line 11, in
session = res[‘sessionId’]
KeyError: ‘sessionId’

Process finished with exit code 1

写回答

1回答

Mushishi

2021-01-18

1、你去看你selenium server stand online的日志

2、或者你把你的res打印出来看一下报错信息

0
4
慕粉1212355798
回复
Mushishi
好的,老师
2021-01-28
共4条回复

助力Python功能测试人员进阶Web自动化测试

轻松转型,快速胜任自动化测试工程师岗位

916 学习 · 607 问题

查看课程