我尝试用本地服务器测试一个自制的本地网站,但是它不起作用... 我收到一些错误消息:
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 :,而我得到了一个空白页
答案 0 :(得分:0)
哦...真是个愚蠢的错误...谢谢!
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个镀铬窗口。具有我想要的结果的一个,但是它在一毫秒后关闭...所以我看不到我想要的结果。最后,只有URL的窗口:data :, 空白页