【问题标题】:How we get value of current url in protractor我们如何在量角器中获取当前 url 的值
【发布时间】:2018-08-27 19:44:45
【问题描述】:

我正在使用量角器 5.2.2。在我们的要求中,我们需要当前 url 的值,根据 Url,我需要做一些特定的操作。我已经使用了下面的代码。

var urlvalue= browser.getCurrentUrl();
if(urlvalue.startsWith("https://accounts.google.com/signin/v2/identifier")){
  ----
}else{
---
}

但它给出了一个错误

TypeError: urlvalue.startsWith is not a function

如何在此处获取 Url 值。在此先感谢。

【问题讨论】:

    标签: protractor


    【解决方案1】:

    我用来检查url是否包含某个字符串的方法是indexOf(如果没有,indexOf的值为-1)。

        browser.getCurrentUrl().then( function( url ) {
      if(url.indexOf("https://accounts.google.com/signin/v2/identifier")>-1){
        - - - -
      }
      else{
        - - - -
      }
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-02
      • 2011-11-11
      • 1970-01-01
      • 2017-03-25
      • 1970-01-01
      • 2019-09-23
      • 2014-01-03
      相关资源
      最近更新 更多