【问题标题】:Can't run cucumber/selenium with chrome不能用铬运行黄瓜/硒
【发布时间】:2018-11-15 15:40:42
【问题描述】:

我尝试使用本地服务器测试自制的本地网站,但它不起作用... 我收到一些错误消息:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"Amount"}
  (Session info: chrome=70.0.3538.102)
  (Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.17134 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds

但我定义了元素:

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException
{
    response.setContentType("text/html");
    response.setStatus(HttpServletResponse.SC_OK);
    response.getWriter().println(
            "<html><head><title>HEADLINE</title></head>" +
                    "<body><form action=\"/withdraw\" method=\"post\">" +
                    "<label for=\"amount\">Amount</label>" +
                    "<input type=\"text\" id=\"amount\" name=\"amount\">" +
                    "<button type=\"submit\" id=\"withdraw\">Withdraw</button>" +
                    "</form></body></html>");
}

但我没有得到标题或其他任何内容......在 Chrome 中,url 是:data:,我得到一个空白页面

【问题讨论】:

  • 从您的错误消息中,我看到给定的 ID- 'Amount' 实际上是 'amount' [更改大小写]。
  • 好吧,测试通过了 :) 但是为什么它这么快,我真的看不到它?

标签: java selenium google-chrome cucumber selenium-chromedriver


【解决方案1】:

哦...多么愚蠢的错误...谢谢!

I get now this massege: java.lang.AssertionError: Incorrect amount dispensed - expected:<20> but was:<0>
    at org.junit.Assert.fail(Assert.java:88)

但这并不奇怪。但 Istill 在 Chrome 中看不到我的“网站”。 在我运行测试时,正在打开 3 个 chrome 窗口。一个具有我想要的结果,但它在一毫秒后关闭......所以我无法真正看到我想要的结果。最后只有带有 url: data: 的窗口, 一个空白页

【讨论】:

    猜你喜欢
    • 2010-11-18
    • 1970-01-01
    • 1970-01-01
    • 2013-04-08
    • 2011-03-04
    • 1970-01-01
    • 2023-03-05
    • 2011-05-17
    • 2019-01-29
    相关资源
    最近更新 更多