Selenium RC Perl script how to get source of xml page?

I wrote a simple perl script with the WWW::Selenium module that interacts with the Selenium RC server and goes to a webpage and downloads the source. I am able to do this with HTML pages. However, I have an XML page I want to download the source of. This is obviously not possible with the 'get_source_html()' function. Below is the script of what i want to do:

#!/usr/bin/perl -sw
use WWW::Selenium;

print "\n setting up Selenium...\n";
my $sel = WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*firefox",
browser_url => "",

print " starting Selenium...\n";


my $xml = $sel->get_html_source();
print $xml;

As you can see the get_html_source is obviously a problem since it will return an error saying that the page is not html. Is there some way that I can just download the current page visible in the browser regardless of the type of page(like the click 'view source' in firefox or even better: some get_source() function)? Also note, that the url I need to use does not end in something like a '.xml' file. The page is generated on the fly if that means anything...

Any wisdom greatly appreciated!


You want the Selenium RC get_page_source() function. It works even if the "page" isn't HTML (even plain text, not just XML).

The Selenium::Remote::Driver Perl module does offer a get_page_source function.

On the other hand, WWW::Selenium does not provide such a method. It only offers a get_html_source function which returns the entire HTML source between the opening and closing "html" tags.

However, a workaround to get the content of an XML document through WWW::Selenium is to use its get_eval function in order to evaluate a JavaScript snippet that will do the job instead. For example, the following line returns the XML contents of the root node/element of the document contained in the browser window:

my $xml = $sel->get_eval("new XMLSerializer().serializeToString(window.document.documentElement)");

try with:


Need Your Help

jquery export to excel, include html th rows

jquery html table csv export

I have the fiddle, modified from another forum that exports an html table to csv with jquery. this works perfectly however I cannot get it to include the table header rows.