gpt4 book ai didi

firefox - Selenium 3 与 Firefox : active did not match a known command

转载 作者:行者123 更新时间:2023-12-02 17:09:32 24 4
gpt4 key购买 nike

我正在尝试使用最新的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)
...

在这两个错误中,事件与已知命令不匹配

如何让它运行?

后续:错误?

查看the code of AbstractHttpCommandCodec.java ,我认为这可能是 org.seleniumhq.selenium:selenium-java 中的错误。

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

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

最佳答案

这是一个 bug现在fixed在 Selenium 3.0 beta 4 中。

关于firefox - Selenium 3 与 Firefox : active did not match a known command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39570283/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com