带有 Firefox 的 Selenium 3:活动与已知命令不匹配
Selenium 3 with Firefox: active did not match a known command
我正在尝试使用最新的 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)
...
在这两个错误中都有 active 与已知命令不匹配。
如何获得此 运行?
跟进:错误?
查看the code of AbstractHttpCommandCodec.java,我认为这可能是org.seleniumhq.selenium中的错误:selenium-java.
defineCommand(GET_ACTIVE_ELEMENT, post("/session/:sessionId/element/active"));
„post“好像不对吧?
我正在尝试使用最新的 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)
...
在这两个错误中都有 active 与已知命令不匹配。
如何获得此 运行?
跟进:错误?
查看the code of AbstractHttpCommandCodec.java,我认为这可能是org.seleniumhq.selenium中的错误:selenium-java.
defineCommand(GET_ACTIVE_ELEMENT, post("/session/:sessionId/element/active"));
„post“好像不对吧?