Changeset 1674
- Timestamp:
- 07/08/08 17:17:35 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
honeyclient/branches/exp/kindlund-selenium/etc/honeyclient.xml
r1649 r1674 86 86 20 87 87 </timeout> 88 <selenium_enable description="If set to 1, then the Agent will attempt to drive the application using Selenium. Otherwise, Win32::Job will be used." default="1"> 89 1 90 </selenium_enable> 88 91 <Browser> 89 92 <IE> … … 95 98 iexplore.exe 96 99 </process_name> 100 <selenium_driver description="The corresponding Selenium browser name to use for this driver." default="*iehta"> 101 *iehta 102 </selenium_driver> 97 103 </IE> 98 104 <FF> … … 104 110 firefox.exe 105 111 </process_name> 112 <selenium_driver description="The corresponding Selenium browser name to use for this driver." default="*chrome"> 113 *chrome 114 </selenium_driver> 106 115 </FF> 107 116 </Browser> honeyclient/branches/exp/kindlund-selenium/lib/HoneyClient/Agent.pm
r1499 r1674 278 278 use Data::Dumper; 279 279 280 # Make sure WWW::Selenium loads. 281 BEGIN { use_ok('WWW::Selenium') or diag("Can't load WWW::Selenium package. Check to make sure the package library is correctly listed within the path."); } 282 require_ok('WWW::Selenium'); 283 use WWW::Selenium; 284 280 285 BEGIN { 281 286 … … 321 326 use HoneyClient::Util::Config qw(getVar); 322 327 328 # Include Selenium Library 329 use WWW::Selenium; 330 323 331 # Include Dumper Library 324 332 use Data::Dumper; … … 345 353 346 354 # Complete URL of SOAP server, when initialized. 347 our $URL_BASE = undef;348 our $URL = undef;355 our $URL_BASE = undef; 356 our $URL = undef; 349 357 350 358 # The process ID of the SOAP server daemon, once created. 351 our $DAEMON_PID = undef; 359 our $DAEMON_PID = undef; 360 361 # Global handle to the Selenium server. 362 our $SELENIUM = undef; 363 364 # Global reference to the driver of the Selenium handle. 365 our $SELENIUM_DRIVER = undef; 352 366 353 367 ####################################################################### … … 465 479 } 466 480 481 # Initialize SOAP Server. 467 482 our $daemon = getServerHandle(address => $args{'address'}, 468 483 port => $args{'port'}); … … 603 618 604 619 { 605 # Status information about the Win32::Job .620 # Status information about the Win32::Job, if used. 606 621 'status' => { 607 622 # The PID of the job, when it was ran. … … 1386 1401 }; 1387 1402 1403 if (getVar(name => "selenium_enable", 1404 namespace => "HoneyClient::Agent::Driver")) { 1405 1406 # Destroy the existing Selenium handle, if our driver changes. 1407 if (defined($SELENIUM) && 1408 ($SELENIUM_DRIVER ne $args{'driver_name'})) { 1409 $SELENIUM->stop(); 1410 $SELENIUM = undef; 1411 } 1412 1413 # Create a new Selenium handle, if need be. 1414 if (!defined($SELENIUM)) { 1415 1416 $SELENIUM = WWW::Selenium->new( 1417 host => "localhost", 1418 port => 4444, 1419 browser => getVar(name => "selenium_driver", 1420 namespace => $args{'driver_name'}), 1421 browser_url => "http://localhost", 1422 ); 1423 $SELENIUM_DRIVER = $args{'driver_name'}; 1424 1425 $SELENIUM->start(); 1426 $SELENIUM->set_timeout($args{'timeout'} * 1000); 1427 $SELENIUM->open("/"); 1428 $SELENIUM->window_maximize(); 1429 $SELENIUM->window_focus(); 1430 } 1431 1432 $LOG->info($args{'driver_name'} . " - Driving To Resource: " . $args{'parameters'}); 1433 eval { 1434 $SELENIUM->open($args{'parameters'}); 1435 }; 1436 if ($@) { 1437 # TODO: This may occur when timeouts hit -- which isn't fatal. 1438 $LOG->error("Error: Unable to drive application. " . $@); 1439 # TODO: Is this needed? 1440 $SELENIUM->stop(); 1441 die SOAP::Fault->faultcode(__PACKAGE__ . "->drive()") 1442 ->faultstring("Error: Unable to drive application. " . $@); 1443 } 1444 1445 } else { 1446 ### TODO: START 1447 1388 1448 # Create a new Job. 1389 1449 my $job = Win32::Job->new(); … … 1444 1504 if ($status->{$processID}->{'exitcode'} != 293) { 1445 1505 $LOG->warn("Unexpected: '" . $processName . "' process (ID = " . $processID . ") terminated early!"); 1506 } 1507 1508 ### TODO: END 1446 1509 } 1447 1510
