How to get Inspect Element code in Selenium WebDriver

I work in selenium with a Firefox browser.

The HTML code shown in the Source Viewer window (CTRL + U) is different from the html code that I see when checking items in Firefox.

when I run driver.getPageSource() i, I get only View source codes (CTRL + U).

Is there any way to access the Mean item code instead of viewing the source code ?

+5
source share
1 answer

I think your question is answered here .

The original html source is what the server sends. I think this is html compilation time or the initial state of the DOM.

The Inspect Element HTML file could be updated using ajax or javascript answers, so it won’t necessarily be the same. I think of it as html runtime or the current state of the DOM.

The GetAttribute () method queries the current state of the DOM element. You can directly return a specific html attribute value

 webElement.GetAttribute("class") 

or get the whole html line.

 webElement.GetAttribute("innerHTML") 
+4
source

Source: https://habr.com/ru/post/1204452/


All Articles