C# Selenium accessing HTML source

C# Selenium accessing HTML source

In order to interact with the entire page source in C#, you need to use the PageSource property of the IWebDriver. This script shows a basic operation that uses the PageSource property to search for a specific string.

var source = driver.PageSource;
if(source.Contains("Wikipedia")) {
    MxService.AddLogLine("Wikipedia found in page source");
} else {
    MxService.AddLogLine("Wikipedia not found in page source");
}

Leave a reply

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

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.