How do I read from an XML File and Use with Selenium RC?

For general discussions about automated software testing tools.

How do I read from an XML File and Use with Selenium RC?

Postby KeithK on Fri Jul 23, 2010 9:17 pm

#Here is my Perl script which is suppose to run in RC use selenium, read from an XML file and verify text of a job description

#!/usr/bin/perl

# use module
use XML::Simple;
use Data::Dumper;

# create object
$xml = new XML::Simple;

# read XML file
$data = $xml->XMLin("jobdata.xml");

# print output
print Dumper($data);

# access XML data
print "$data->{Description} \n";

use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;

my $sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*firefox",
browser_url => "http://www.sqaresources.com/" );

$sel->open_ok("/");
$sel->click_ok("Image1");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("Image9");
$sel->wait_for_page_to_load_ok("30000");
$sel->is_text_present_ok("$jobdata->{job}->{Description}");



#This is the data contained in the XML File jobdata.xml:
<?xml version='1.0'?>
<Job>

<Description>
* Java, SQL, Web Based Testing, LAMP (Linux, Apache, MySql, Perl/PHP)
* Use agile / scrum practices
* Responsible for the developing planning, execution, scheduling, and reporting of tests suites
* Build, maintain, and extend regression and automation suites
* Participate as a team member in testing, analysis, process management to identify and communicate risks
</Description>
</Job>

#after running get the follwing error:
Global symbol "$jobdata" requires explicit package name at perl
Execution of perlxml2.pl aborted due to compilation errors.


Want to know what is the correct syntax for the selenium is_text_present_ok for jobdata
KeithK
 
Posts: 2
Joined: Sat May 08, 2010 6:49 pm

Return to Automated Testing

Who is online

Users browsing this forum: No registered users and 0 guests


cron