【发布时间】: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