How to Get HTML Source of WebElement in Selenium WebDriver using Python

How to Get HTML Source of WebElement in Selenium WebDriver using Python,While working with Selenium WebDriver scripting using any language bindings whether it is a Python,Java or Ruby,we require to verify Expected Results with Actual results to check Test case is PASS or FAIL.In this selenium WebDriver using python post you will learn Get HTML Source of WebElement in Selenium WebDriver using Python languages.


Get HTML Source of WebElement in Selenium WebDriver using Python


I'm using python bindings to create Selenium Webdriver Test scripts,till now you've learn Selenium Webdriver Test scripting with JAVA but coming to Python language it is completely different.

We can read WebElement source with the help of innerHTML attribute to get the Element Source of the Content.

Using chromeDriver to open Google Chrome Browser.

Different Language code to Get HTML Source of WebElement in Selenium WebDriver,Please use below different code to use in Selenium webdriver Test Scripts.

PYTHON:

element.get_attribute('innerHTML')


PHP:

$elem.getAttribute('innerHTML');


JAVA:

elem.getAttribute("innerHTML");


C#:

element.GetAttribute("innerHTML");


RUBY:

element.attribute("innerHTML")


JS:

element.getAttribute('innerHTML');

No comments:

Post a Comment