Hi guys and girls,
I'm currently trying to write some Perl scripts where a series of webpages are accessed and certain details such as name and coursename are to be entered into the appropriate fields using an xml file that I have created. However, when I run the script the details from the XML file are not being inserted and instead it's placing a random jumble of numbers such as Array (00xcf0040). I think this is because the script is placing the name of the array rather than the data within it.
If you guys could offer any tips or pointers I'd be most appreciative.
FYI, I've included the XML and the script below. In case anyone is wondering I'm currently testing with Selenium.
Thanks!
XML
<?xml version="1.0" encoding="utf-8"?>
<courses>
<name>Chemistry</name>
<shortname>CHEM1</shortname>
<name>Physics</name>
<shortname>PHYS1</shortname>
<name>Biology</name>
<shortname>BIOL1</shortname>
</courses>
Script
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
use XML::Simple;
use Data:
umper;
my $xml = new XML::Simple;
my $data = $xml->XMLin("Courselist.xml", KeyAttr=>'courses');
my $sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*chrome",
browser_url => "http://localhost/moodle/" );
$sel->open_ok("/moodle/");
my $count = 4;
until ($count = 0) {
$sel->click_ok("link=Courses");
$sel->click_ok("link=Add/edit courses");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("//input[\@value='Add a new course']");
$sel->wait_for_page_to_load_ok("30000");
$sel->type_ok("id_fullname", ($data->{name}));
$sel->type_ok("id_shortname",($data->{shortname}));
$sel->click_ok("id_submitbutton");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("//input[\@value='Click here to enter your course']");
$sel->wait_for_page_to_load_ok("30000");
$sel->open_ok("/moodle/");
$count--;
}
I'm currently trying to write some Perl scripts where a series of webpages are accessed and certain details such as name and coursename are to be entered into the appropriate fields using an xml file that I have created. However, when I run the script the details from the XML file are not being inserted and instead it's placing a random jumble of numbers such as Array (00xcf0040). I think this is because the script is placing the name of the array rather than the data within it.
If you guys could offer any tips or pointers I'd be most appreciative.
FYI, I've included the XML and the script below. In case anyone is wondering I'm currently testing with Selenium.
Thanks!
XML
<?xml version="1.0" encoding="utf-8"?>
<courses>
<name>Chemistry</name>
<shortname>CHEM1</shortname>
<name>Physics</name>
<shortname>PHYS1</shortname>
<name>Biology</name>
<shortname>BIOL1</shortname>
</courses>
Script
use strict;
use warnings;
use Time::HiRes qw(sleep);
use Test::WWW::Selenium;
use Test::More "no_plan";
use Test::Exception;
use XML::Simple;
use Data:
my $xml = new XML::Simple;
my $data = $xml->XMLin("Courselist.xml", KeyAttr=>'courses');
my $sel = Test::WWW::Selenium->new( host => "localhost",
port => 4444,
browser => "*chrome",
browser_url => "http://localhost/moodle/" );
$sel->open_ok("/moodle/");
my $count = 4;
until ($count = 0) {
$sel->click_ok("link=Courses");
$sel->click_ok("link=Add/edit courses");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("//input[\@value='Add a new course']");
$sel->wait_for_page_to_load_ok("30000");
$sel->type_ok("id_fullname", ($data->{name}));
$sel->type_ok("id_shortname",($data->{shortname}));
$sel->click_ok("id_submitbutton");
$sel->wait_for_page_to_load_ok("30000");
$sel->click_ok("//input[\@value='Click here to enter your course']");
$sel->wait_for_page_to_load_ok("30000");
$sel->open_ok("/moodle/");
$count--;
}