zoukankan      html  css  js  c++  java
  • 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.Study30.自动化测试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.Study30.自动化测试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"是如何确定下来的?

  • 相关阅读:
    aws-rds for mysql 5.7.34搭建备库
    Redis 未授权访问漏洞利用总结(转)
    mongoexport/mongimport命令详解
    mongodump/mongorestore命令详解
    redis stream类型 常用命令
    system_time_zone参数值由来
    MySQL加密解密函数AES_ENCRYPT AES_DECRYPT
    MySQL开启SSL加密
    MDL锁获取顺序和优先先
    explicit_defaults_for_timestamp 参数说明
  • 原文地址:https://www.cnblogs.com/hadas/p/13180103.html
Copyright © 2011-2022 走看看