当我执行以下代码时:
driver.findElement(By.className("qview-product-name")).click();
我收到以下错误
Session ID: d5df6f837164b1738991e8dc09027fe0
*** Element info: {Using=class name, value=qview-product-name}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByClassName(RemoteWebDriver.java:412)
at org.openqa.selenium.By$ByClassName.findElement(By.java:389)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
at Logins.bcLogin(Logins.java:140)
at Exception.main(Exception.java:54)
我正在处理的网页肯定包含以下 HTML 代码,我尝试等待适当的时间来执行。
<dd class="qview-product-name">
<span class="note">1 x </span>
<a href="Link_here"_blank">Title</a>
</dd>
我以为我很擅长使用各种方法定位元素,但这让我很难过。关于我应该如何进行故障排除的任何想法?谢谢!