【问题标题】:protractor actions.keydown vs selenium actions.keydown量角器 actions.keydown 与 selenium actions.keydown
【发布时间】:2019-04-05 18:17:24
【问题描述】:

量角器:5.4.1 硒:3.14 壁虎司机:0.23 浏览器:火狐

您好,执行以下代码时出现错误“失败:sendKeysToActiveElement”

browser.actions().keyDown(protractor.Key.CONTROL).click(elements).keyUp(protractor.Key.CONTROL).perform()

但是,如果我尝试使用 selenium 而不是量角器运行它,它可以使用以下代码

driver.actions({bridge:true}).keyDown(webdriver.Key.CONTROL).click(elements).keyUp(webdriver.Key.CONTROL).perform();

有人有这方面的经验吗?

【问题讨论】:

    标签: selenium-webdriver protractor geckodriver


    【解决方案1】:

    ProtractorSelenium JS 代码 sn-ps 的区别在于表单在 桥接模式 下不执行操作,而后者执行。

    来自硒source at v3.14

     * In bridge mode, {@link #perform perform()} will first attempt to execute the
     * configured action sequence using the W3C action protocol. If this is rejected
     * by the remote end, the sequence will be translated to and executed against
     * the legacy protocol.
    

    Gecko webdriver 似乎不支持W3C action protocol,操作错误为thrown

      if (this.bridge_
          && (ex instanceof UnknownCommandError
              || ex instanceof UnsupportedOperationError)) {
        return executeLegacy(this.executor_, this.sequences_);
      }
      throw ex;
    

    尝试在桥接模式下运行您的操作以进行量角器测试。

    actions = browser.actions({bridge: true})
    actions.keyDown(protractor.Key.CONTROL)
      .click(elements)
      .keyUp(protractor.Key.CONTROL)
      .perform()
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多