• 《SeleniumBasic 3.141.0.0


    Capabilities类用于修改Web驱动程序的多个属性。Desired capabilities类提供一组键值对key-value,用于更改web驱动程序的各个属性,如浏览器名称、浏览器平台等。

    SeleniumBasic中执行如下程序:

    Dim Caps As SeleniumBasic.ICapabilities
    Set Caps = WD.Capabilities
    Debug.Print Caps.ToString

    立即窗口打印出一个JSON格式的字符串

    {
      "acceptInsecureCerts": false,
      "browserName": "chrome",
      "browserVersion": "85.0.4183.102",
      "chrome": {
        "chromedriverVersion": "85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689})",
        "userDataDir": "C:\Users\ADMINI~1\AppData\Local\Temp\scoped_dir4632_532329042"
      },
      "goog:chromeOptions": {
        "debuggerAddress": "localhost:49840"
      },
      "networkConnectionEnabled": false,
      "pageLoadStrategy": "normal",
      "platformName": "windows",
      "proxy": {},
      "setWindowRect": true,
      "strictFileInteractability": false,
      "timeouts": {
        "implicit": 0,
        "pageLoad": 300000,
        "script": 30000
      },
      "unhandledPromptBehavior": "dismiss and notify",
      "webauthn:virtualAuthenticators": true
    }

    可以看到包含browserName等键值对。

    还可以直接抽取到其中某个信息,例如获取browserVersion,浏览器的版本信息。

    Dim s1 As String
    s1 = Caps.GetCapability("browserVersion")
    Debug.Print Caps.HasCapability("browserVersion")
    Dim v As Variant
    v = Caps.Item("browserVersion")
    Debug.Print v

    上述代码,变量s1和v的结果都是85.0.4183.102

    如果打开的是其他浏览器,信息也会相应的不同。例如启动Firefox浏览器

    WD.New_FirefoxDriver Service:=Service, Options:=Options
    WD.URL = "https://www.baidu.com"
    Debug.Print WD.Capabilities.ToString

    出来的结果是:

    {
      "acceptInsecureCerts": false,
      "browserName": "firefox",
      "browserVersion": "80.0.1",
      "moz:accessibilityChecks": false,
      "moz:buildID": "20200831163820",
      "moz:geckodriverVersion": "0.26.0",
      "moz:headless": false,
      "moz:processID": 4560,
      "moz:profile": "C:\Users\Administrator\AppData\Local\Temp\rust_mozprofilesdDqbl",
      "moz:shutdownTimeout": 60000,
      "moz:useNonSpecCompliantPointerOrigin": false,
      "moz:webdriverClick": true,
      "pageLoadStrategy": "normal",
      "platformName": "windows",
      "platformVersion": "10.0",
      "rotatable": false,
      "setWindowRect": true,
      "strictFileInteractability": false,
      "timeouts": {
        "implicit": 0,
        "pageLoad": 300000,
        "script": 30000
      },
      "unhandledPromptBehavior": "dismiss and notify"
    }
  • 相关阅读:
    [置顶] 宏途_LCD调试流程.
    字典树的数据结构及基本算法的实现
    uva 10714 Ants(贪心)
    paip.输入法编程---增加码表类型
    chomp方法
    ios 限制输入长度
    我所理解的设计模式(C++实现)——策略模式(Strategy Pattern)
    Android用户界面 UI组件--AdapterView及其子类(一) ListView及各种Adapter详解
    C#系列教程——switch定义及使用
    局域网内linux由ip反解析主机名
  • 原文地址:https://www.cnblogs.com/ryueifu-VBA/p/13696768.html
Copyright © 2020-2023  润新知