Search code examples
firefoxselenium-webdriverscalatestgeckodriver

Selenium 3 with Firefox: active did not match a known command


I am trying to write a test which involves the latest Firefox (48.0.2) using the lastest geckodriver.exe (v0.10.0) and the following dependencies.

<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>

My test starts like this

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")        
}

First I tried with Chrome which was fine. But with Firefox I already get an error for 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)
...

As a workaround If I replaced enter(username) with usernameField.value = username, etc. The next error comes for 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)
...

In both errors there is this active did not match a known command.

How do I get this running?

followup: bug?

Looking at the code of AbstractHttpCommandCodec.java, I think it could be a bug in org.seleniumhq.selenium:selenium-java.

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

„post“ seems wrong, doesn’t it?


Solution

  • It was a bug now fixed in Selenium 3.0 beta 4.