【问题标题】:How to verify parametr from request URL? (Selenium)如何验证来自请求 URL 的参数? (硒)
【发布时间】:2020-05-29 03:36:58
【问题描述】:

我在那个页面上:

http://localhost:8080/login?error=true

我如何检查 error 变量是否包含值 true?

这是我失败的尝试:

错误:

[info] Executing: | assertAttribute | error | true |
[info] Wait until the element is found
[error] Implicit Wait timed out after 10000ms
[error] Element erro not found

我正在使用:

  1. Selenium IDE ---> 3.16.1
  2. Katalon 录音机 ---> 4.0.0
  3. Chrome 64 位 ---> 79.0.3945.130

我是测试领域的新手。有人可以帮忙吗? :(

【问题讨论】:

    标签: selenium selenium-ide katalon-recorder


    【解决方案1】:

    Assert Attribute 命令用于检查 DOM 元素的属性。所以这里需要用到js:

    execute script | var url = window.location.href; return /error=true/.test(url); |flag
    assert | flag | true
    

    【讨论】:

      【解决方案2】:

      下面的代码将起作用

      driver = webdriver.Firefox()
      driver.get('http://localhost:8080/login')
      currentURL = driver.current_url
      x = currentURL.find('error=true')
      if x == -1:
          print("error=true")
      

      【讨论】:

      • hmm 当我使用 Selenium IDE 时如何实现这样的代码? :
      猜你喜欢
      • 1970-01-01
      • 2020-02-13
      • 2021-12-21
      • 1970-01-01
      • 1970-01-01
      • 2021-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多