<small id='u8KBg'></small><noframes id='u8KBg'>

    <bdo id='u8KBg'></bdo><ul id='u8KBg'></ul>
    1. <i id='u8KBg'><tr id='u8KBg'><dt id='u8KBg'><q id='u8KBg'><span id='u8KBg'><b id='u8KBg'><form id='u8KBg'><ins id='u8KBg'></ins><ul id='u8KBg'></ul><sub id='u8KBg'></sub></form><legend id='u8KBg'></legend><bdo id='u8KBg'><pre id='u8KBg'><center id='u8KBg'></center></pre></bdo></b><th id='u8KBg'></th></span></q></dt></tr></i><div id='u8KBg'><tfoot id='u8KBg'></tfoot><dl id='u8KBg'><fieldset id='u8KBg'></fieldset></dl></div>

      1. <legend id='u8KBg'><style id='u8KBg'><dir id='u8KBg'><q id='u8KBg'></q></dir></style></legend>

        <tfoot id='u8KBg'></tfoot>

        sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native

        时间:2023-09-28

      2. <i id='2Ncbw'><tr id='2Ncbw'><dt id='2Ncbw'><q id='2Ncbw'><span id='2Ncbw'><b id='2Ncbw'><form id='2Ncbw'><ins id='2Ncbw'></ins><ul id='2Ncbw'></ul><sub id='2Ncbw'></sub></form><legend id='2Ncbw'></legend><bdo id='2Ncbw'><pre id='2Ncbw'><center id='2Ncbw'></center></pre></bdo></b><th id='2Ncbw'></th></span></q></dt></tr></i><div id='2Ncbw'><tfoot id='2Ncbw'></tfoot><dl id='2Ncbw'><fieldset id='2Ncbw'></fieldset></dl></div>

          <bdo id='2Ncbw'></bdo><ul id='2Ncbw'></ul>
            <tfoot id='2Ncbw'></tfoot>
          • <legend id='2Ncbw'><style id='2Ncbw'><dir id='2Ncbw'><q id='2Ncbw'></q></dir></style></legend>
            • <small id='2Ncbw'></small><noframes id='2Ncbw'>

                <tbody id='2Ncbw'></tbody>

                  本文介绍了sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 通过 Selenium 和 Java 使用 findElement(By.className())的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  当我执行以下代码时:

                  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 代码,我已尝试等待适当的时间来执行.

                  The webpage I am working on definately contains the following HTML code and I have tried waiting an appropriate amount of time to execute.

                  <dd class="qview-product-name">
                      <span class="note">1 x </span>
                                      <a href="Link_here"_blank">Title</a>
                              </dd>
                  

                  我以为我在使用各种方法定位元素方面已经做得很好了,但这让我很难过.关于我应该如何进行故障排除的任何想法?谢谢!

                  I thought I was getting pretty good at locating elements using the various methods, but this has me stumped. Any ideas on how I should go about troubleshooting? Thanks!

                  推荐答案

                  您需要注意以下几点:

                  • By.className("qview-product-name") 指的是父 <dd> 标签,可能不是您想要单击的所需元素.相反,您的用例必须是单击 <a href="Link_here"_blank">Title</a> 元素.
                  • 根据最佳实践,在调用 click() 时,您需要为 elementToBeClickable()WebDriverWait> 并且您可以使用以下任一定位器策略:

                  • By.className("qview-product-name") refers to the parent <dd> tag and perhaps is not the desired element you want to click. Rather your usecase must be to click on the <a href="Link_here"_blank">Title</a> element.
                  • As per best practices, while invoking click() you need to induce you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

                  linkText:

                  new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.linkText("Title"))).click();
                  

                1. cssSelector:

                  new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("dd.qview-product-name a[href='Link_here']"))).click();
                  

                2. xpath:

                  new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//dd[@class='qview-product-name']//a[@href='Link_here' and text()='Title']"))).click();
                  

                3. 确保:

                  • JDK 升级到当前级别 JDK 8u222.
                  • Selenium 已升级到当前级别版本 3.141.59.
                  • ChromeDriver 已更新为当前 ChromeDriver v77.0 级别.
                  • Chrome 已更新至当前 Chrome 版本 77.0 级别.(根据 ChromeDriver v77.0 发行说明)
                  • 清理你的项目工作区通过你的IDE重建你的项目只需要依赖.
                  • 如果您的基本 Web 客户端 版本太旧,请卸载它并安装最新的 GA 和发布版本的 Web 客户端.
                  • 进行一次系统重启.
                  • 非 root 用户身份执行您的 @Test.
                  • JDK is upgraded to current levels JDK 8u222.
                  • Selenium is upgraded to current levels Version 3.141.59.
                  • ChromeDriver is updated to current ChromeDriver v77.0 level.
                  • Chrome is updated to the current Chrome Version 77.0 level. (as per ChromeDriver v77.0 release notes)
                  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
                  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
                  • Take a System Reboot.
                  • Execute your @Test as non-root user.

                  这篇关于sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 通过 Selenium 和 Java 使用 findElement(By.className())的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何修复未知错误:未处理的检查器错误:“找不到 下一篇:java.lang.IllegalStateException:驱动程序可执行文件不存

                  相关文章

                  最新文章

                  <i id='9EbGx'><tr id='9EbGx'><dt id='9EbGx'><q id='9EbGx'><span id='9EbGx'><b id='9EbGx'><form id='9EbGx'><ins id='9EbGx'></ins><ul id='9EbGx'></ul><sub id='9EbGx'></sub></form><legend id='9EbGx'></legend><bdo id='9EbGx'><pre id='9EbGx'><center id='9EbGx'></center></pre></bdo></b><th id='9EbGx'></th></span></q></dt></tr></i><div id='9EbGx'><tfoot id='9EbGx'></tfoot><dl id='9EbGx'><fieldset id='9EbGx'></fieldset></dl></div>
                  • <bdo id='9EbGx'></bdo><ul id='9EbGx'></ul>
                4. <tfoot id='9EbGx'></tfoot><legend id='9EbGx'><style id='9EbGx'><dir id='9EbGx'><q id='9EbGx'></q></dir></style></legend>

                    1. <small id='9EbGx'></small><noframes id='9EbGx'>