#!/usr/bin/perl ################################################################################ # # Campus Pipeline / Luminis Portal / uPortal Load Tester v1.2 # # Walt Howd - 03/09/06 # # This script automatically logon to Luminis and navigate through the defined tabs. It uses the Internet Explorer COM Object # so it will only work on the Windows platform. # ################################################################################ ######################################## # # Configuration Variables # ######################################## $logonURL = "https://luminis-server/cp/home/displaylogin"; $username = "username"; $password = "password"; # $visible = 1; # Set to to zero to hide the browser $tabIterations = 250; # Number of times to navigate through the urls before quitting $navSleepSec = 1; # Time in seconds to sleep in between navigation # You can put a list of URLS here to have the script navigate to @tabs = qw( http://luminis-server/cp/tag.f8853426dbb13fa7.render.userLayoutRootNode.uP?uP_root=root&uP_sparam=activeTab&activeTab=u11l1s18&uP_tparam=frm&frm= http://luminis-server/cp/tag.f8853426dbb13fa7.render.userLayoutRootNode.uP?uP_root=root&uP_sparam=activeTab&activeTab=u11l1s65&uP_tparam=frm&frm= http://luminis-server/cp/tag.f8853426dbb13fa7.render.userLayoutRootNode.uP?uP_root=root&uP_sparam=activeTab&activeTab=u14l1s8&uP_tparam=frm&frm= http://luminis-server/cp/tag.f8853426dbb13fa7.render.userLayoutRootNode.uP?uP_root=root&uP_sparam=activeTab&activeTab=s8&uP_tparam=frm&frm= http://luminis-server/misc/timedout2.html ); ######################################## # # Initiate the Internet Explorer COM Object # ######################################## use Win32::OLE; $browser = Win32::OLE->new('InternetExplorer.Application', 'Quit'); $browser->{'Visible'} = $visible; logon(); ######################################## # # Navigate through tabs # ######################################## for($j=0; $j<$tabIterations; $j++) { foreach $url (@tabs) { $browser->Navigate($url); print "Navigating pass $j to $url. . .\n\n"; while($browser->Busy) { print "."; sleep($navSleepSec); } sleep($navSleepSec); if($browser->Document->Body->innerHTML =~ /session expired/ig) { print "Session has expired. Waiting and logging in again. . .\n\n"; sleep($navSleepSec); logon(); } } } sub logon() { ######################################## # # Navigate to the logon page # ######################################## sleep($navSleepSec); $browser->Navigate($logonURL); while($browser->Busy) { print "."; sleep($navSleepSec); } sleep($navSleepSec); ######################################## # # Find the form and fill in the username and password fields # ######################################## my $i = 0; my $j = 0; for ($i=0; $i<$browser->Document->all->length; $i++) { if($browser->Document->all($i)->tagName =~ /^form$/i) { my $form = $browser->Document->all($i); for ($j=0; $j < $form->all->length; $j++) { if($form->all($j)->getAttribute("name") =~ /^user$/i) { $form->all($j)->{value} = $username; } if($form->all($j)->getAttribute("name") =~ /^pass$/i) { $form->all($j)->{value} = $password; } } } } ######################################## # # Submit the form to logon # ######################################## $browser->document->cplogin->submit(); while($browser->Busy) { print "."; sleep($navSleepSec); } sleep($navSleepSec); if($browser->Document->Body->innerHTML =~ /password/ig) { die("Bad password, could not logon"); } }