Saturday 11 November 2017

Code to save IWebDriver.PageSource in XML file

The Following snippet is most of the time used while working on Automation using WinAppDriver


driver - RemoteWebDriver instance


System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(driver.PageSource.ToString());
System.Xml.XmlTextWriter writer = 
     new System.Xml.XmlTextWriter(@"c:\App_To_XML.xml", 
                   new System.Text.UnicodeEncoding());
writer.Formatting = System.Xml.Formatting.Indented;
doc.WriteContentTo(writer);


-Pankaj Dhapola
Let's Think on it

1 comment:

Unknown said...

Hi Pankaj, Does Winium driver support desktop applications having embedded HTML ? I mean desktop applications having web forms. For eg. Microsoft Crm Dynamics 365. Any help would be appreciated..