How to parse entire DOM elements and follow changes in DOM using selenium webdriver in java

tupac shakur :

I have a URL which I want to test the changes in it if I browse to this URL several time , meaning: If this is the first time that a test is running on this url, only save the layout (DOM) of the page. and I want to be able to produce output which will contain the following: list of all changes on this url, changes mean - new HTML elements added to the page, old elements was removed, elements location have changed.

So far what I started to do with selenium is:

public String extractingUrlDom(){
        this.driver.get("https://www.google.com/");
        this.str = driver.getPageSource().toString();
        return str;
    }

My question is how do I track all changes that was done to the DOM after browsing to the same URL (if any changes were done).

JeffC :

You would need to write the HTML to a text file in a specific location. When a test runs, it would check that location for the expected filename. If it doesn't exist, it's the first time the test was run and it would save the HTML to the file. If a file does exist, you would open the existing file and do a diff of the two HTML strings. You could then write that diff out to a separate file.

There's more logic that you would want to consider but this should be enough to get you started. There are plenty of diffing engines/libraries out there, you should be able to find an existing one and use it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to automate shadow DOM elements using selenium?

How to get value from DOM window in Selenium webdriver(Java)

Selenium WebDriver Java: Change DOM before DOMContentLoaded

Selenium Webdriver with Shadow DOM

parse xml using dom java

How to automate/access nested shadow DOM elements using selenium python?

How can I count the elements in the DOM element using nUnit, Selenium?

How to click on SVG elements using XPath and Selenium WebDriver through Java

How to get multiple elements (div) using Xpath Selenium WebDriver JAVA?

How to Parse XML without using DOM or SAX Parser in Java?

How to check whether an element on the DOM is in the foreground in Selenium using Java?

How to handle a web element getting removed from DOM using Selenium Webdriver?

How to extract the ID attribute of a DOM element, if i know corresponding text through Selenium Webdriver and Java

How to click the DOM element in selenium webdriver thru C#

How to refresh Selenium Webdriver DOM data without reloading page?

How to find a div element in DOM code with selenium webdriver and python?

Detect changes in DOM elements order

How to parse a list using simple html dom

How to parse a DocumentFragment with with the Java standard DOM API

Javascript button that changes properties of html elements using DOM Events

How to delete DOM element from Selenium Java

How to get the entire web page source using Selenium WebDriver in python

How to compare two DOM elements using Cypress?

how to Get an id of DOM elements using JQuery

How to parse DOM (REACT)

can we able to iterate DOM elements in selenium java

How to parse multiple elements in portions for html via Simple Html Dom

DOMXpath/DOMDocument - How to parse HTML dom elements not only with simple text

Element is no longer attached to the DOM selenium webdriver