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.

Selenium Webdriver Using Python – Complete Tutorial Guide

ALSO READ  How to Add Screenshots to TestNG Report

Get HTML Source of WebElement in Selenium 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');

Rajesh K

Leave a Reply

Your email address will not be published. Required fields are marked *