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