3-12通过selenium从request中查看sessionId

代码:

#coding=utf-8
from selenium import webdriver
import json
import requests

##############3-12:request实现打开地址封装_start################
url = 'http://127.0.0.1:4444/wd/hub/session'
data = json.dumps({
    'desiredCapabilities':{
        'browserName':'MicrosoftEdge'
    }
})
res = requests.post(url,data).json()
session =  res['sessionId']
print(session)
##############3-12:request实现打开地址封装_end################

结果:

1.VSCode日志:

PS E:\30.Study\30.自动化测试\99.零基础入门 Python Web 自动化测试\10.seleniumCodePractice> & "C:/Program Files/Python38/python.exe" "e:/30.Study/30.自动化测试/99.零基础
入门 Python Web 自动化测试/10.seleniumCodePractice/202006/open_browser_3-12.py"
2928e4f0ddadff0975d90cddfba68260
PS E:\30.Study\30.自动化测试\99.零基础入门 Python Web 自动化测试\10.seleniumCodePractice>

2.cmd日志:
07:02:08.903 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "MicrosoftEdge"
}
07:02:08.904 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.edge.EdgeDriverService)
Starting MSEdgeDriver 83.0.478.50 (4e8532eb6939de0932c9d36c59227be3a4e49bef) on port 22392
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping MSEdgeDriver safe.
MSEdgeDriver was started successfully.
07:02:12.075 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
07:02:12.094 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 2928e4f0ddadff0975d90cddfba68260 (org.openqa.selenium.edge.EdgeDriverService)

思考:

session =  res['sessionId']中的"sessionId"是如何确定下来的?

 

posted on 2020-06-23 07:08  shiberhou  阅读(931)  评论(0编辑  收藏  举报

导航