4

我正在尝试使用最新的geckodriver.exe (v0.10.0)和以下依赖项编写一个涉及最新Firefox (48.0.2)的测试。

<dependencies>
    <dependency>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest_2.11</artifactId>
        <version>3.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <!-- version 3 is needed for current Firefox -->
        <version>3.0.0-beta3</version>
    </dependency>
</dependencies>

我的测试是这样开始的

class LoginSpec extends FeatureSpec with GivenWhenThen with Firefox 
{
    val website = "http://localhost:8080/"

    feature("Landing page")
    {    
        scenario("Wrong password")
        {
          Given("someone on the website")
          go to website

          When("he tries to login with a wrong password")
          login("mbee", "bad password")

          Then("he will stay on the login page")
          usernameField.isDisplayed
          passwordField.isDisplayed
        }
    }

    def login(username: String, password: String)
    {
      click on usernameField
      enter(username)
      click on passwordField
      enter(password)
      submit()
    }

    def usernameField = textField("j_username")

    def passwordField = pwdField("j_password")        
}

首先,我尝试使用 Chrome,这很好。但是对于 Firefox,我已经收到了以下错误enter(username)

org.openqa.selenium.UnsupportedCommandException: POST /session/2769cbe9-f066-4a63-ad49-990eec1c6740/element/active did not match a known command (WARNING: The server did not provide any stacktrace information)
...
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.activeElement(RemoteWebDriver.java:968)
    at org.scalatest.selenium.WebBrowser$ActiveElementTarget.switch(WebBrowser.scala:1502)
    at org.scalatest.selenium.WebBrowser$ActiveElementTarget.switch(WebBrowser.scala:1494)
    at org.scalatest.selenium.WebBrowser$switch$.to(WebBrowser.scala:3948)
    at org.scalatest.selenium.WebBrowser$class.enter(WebBrowser.scala:4463)
    at com.iomedico.iostudyoffice.LoginSpec.enter(LoginSpec.scala:18)
    at com.iomedico.iostudyoffice.LoginSpec.login(LoginSpec.scala:100)
...

作为一种解决方法,如果我替换enter(username)usernameField.value = username等。下一个错误来自submit()

WebDriver encountered problem to submit(): POST /session/c423793f-09a0-4a8e-afc0-7a2d6d1f3d6a/element/active did not match a known command (WARNING: The server did not provide any stacktrace information)
...
    at org.scalatest.selenium.WebBrowser$class.submit(WebBrowser.scala:3870)
    at com.iomedico.iostudyoffice.LoginSpec.submit(LoginSpec.scala:18)
    at com.iomedico.iostudyoffice.LoginSpec.login(LoginSpec.scala:105)
...

在这两个错误中,都存在此活动与已知命令不匹配

我如何让它运行?

跟进:错误?

查看AbstractHttpCommandCodec.java 的代码,我认为这可能是 org.seleniumhq.selenium: selenium-java中的一个错误。

defineCommand(GET_ACTIVE_ELEMENT, post("/session/:sessionId/element/active"));

“post”似乎是错误的,不是吗?

4

1 回答 1

2

这是现在在 Selenium 3.0 beta 4 中修复的错误。

于 2016-09-27T07:48:16.283 回答