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

    <small id='3SKmV'></small><noframes id='3SKmV'>

    • <bdo id='3SKmV'></bdo><ul id='3SKmV'></ul>

    1. <legend id='3SKmV'><style id='3SKmV'><dir id='3SKmV'><q id='3SKmV'></q></dir></style></legend>
        <tfoot id='3SKmV'></tfoot>

        WebDriver 从页面中删除元素

        WebDriver remove element from page(WebDriver 从页面中删除元素)
          <bdo id='DgaPj'></bdo><ul id='DgaPj'></ul>
          <tfoot id='DgaPj'></tfoot>
          <i id='DgaPj'><tr id='DgaPj'><dt id='DgaPj'><q id='DgaPj'><span id='DgaPj'><b id='DgaPj'><form id='DgaPj'><ins id='DgaPj'></ins><ul id='DgaPj'></ul><sub id='DgaPj'></sub></form><legend id='DgaPj'></legend><bdo id='DgaPj'><pre id='DgaPj'><center id='DgaPj'></center></pre></bdo></b><th id='DgaPj'></th></span></q></dt></tr></i><div id='DgaPj'><tfoot id='DgaPj'></tfoot><dl id='DgaPj'><fieldset id='DgaPj'></fieldset></dl></div>
        • <legend id='DgaPj'><style id='DgaPj'><dir id='DgaPj'><q id='DgaPj'></q></dir></style></legend>

                <tbody id='DgaPj'></tbody>

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

                  本文介绍了WebDriver 从页面中删除元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 Selenium WebDriver(ChromeDriver).处理后我需要从页面中删除一些元素(来自 DOM 模型).

                  I'm using Selenium WebDriver(ChromeDriver). I need to remove some elements from page after processing(from DOM model).

                  例如我有以下元素:

                  WebElement starRatingElement = reviewElement.findElement(By.className("review-info-star"));
                  

                  如何从浏览器 DOM 模型中移除 starRatingElement ?

                  How to remove starRatingElement from browser DOM model ?

                  如何使用 Selenium WebDriver 在 Java 中实现?请举个例子.

                  How it can be achieved in Java with Selenium WebDriver ? Please show an example.

                  推荐答案

                  您必须执行 JavaScript 代码才能进行任何 DOM 更改.

                  You'll have to execute a JavaScript code to make any DOM changes.

                  WebDriver driver = new ChromeDriver();
                  JavascriptExecutor js;
                  if (driver instanceof JavascriptExecutor) {
                      js = (JavascriptExecutor) driver;
                  }
                  js.executeScript("return document.getElementsByClassName('review-info-star')[0].remove();");
                  

                  这篇关于WebDriver 从页面中删除元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                  <tfoot id='oAB6a'></tfoot>
                        <bdo id='oAB6a'></bdo><ul id='oAB6a'></ul>

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

                            <legend id='oAB6a'><style id='oAB6a'><dir id='oAB6a'><q id='oAB6a'></q></dir></style></legend>
                              <tbody id='oAB6a'></tbody>