This is a migrated thread and some comments may be shown as answers.

Copying the content of a webpage and saving as XML

1 Answer 1101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Reddy
Top achievements
Rank 1
Reddy asked on 11 Jun 2012, 06:07 PM
I need to copy the content of a webpage and save it as an XML. I noticed that the webpage is displaying a xml file and when i click on view source, i still see an xml file but when i am using a coded step on TestStudio to get the source "ActiveBrowser.ViewSourceString.ToString", i am getting HTML code as output.
      So i need to just copy the content of the web page directly and save it as an XML.

Thank you,
Nithin

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 14 Jun 2012, 03:15 PM
Hello Nithin,

So the XML file is being loaded directly in the browser? If so, Test Studio has no built-in functionality to deal with it. The result you see with ActiveBrowser.ViewSourceString is expected.

I came up with a work-around, however, using "Blind" Key Presses and Typing. You'll use the "Save" shortcut and specify where to save the file:

Manager.Desktop.KeyBoard.KeyDown(System.Windows.Forms.Keys.ControlKey);
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.S);
Manager.Desktop.KeyBoard.KeyUp(System.Windows.Forms.Keys.ControlKey);
 
System.Threading.Thread.Sleep(1000);
 
string saveLocation = string.Format("test-{0:HH-mm-ss}.xml", DateTime.Now);
Manager.Desktop.KeyBoard.TypeText(@"C:\temp\" + saveLocation, 5);
Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter);

Ensure you add a reference to System.Windows.Forms. If you prefer Visual Basic, use our code converter

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Reddy
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or