Created
July 15, 2013 01:40
-
-
Save daluu/5996952 to your computer and use it in GitHub Desktop.
Example code snippets showing how Robot Framework test libraries and remote servers can be used externally with other frameworks and tools like PHPUnit. Note that it only presents code from the PHP side, not the RF remote server & library side, which a RF user/developer should already be familiar with.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include_once dirname(__FILE__) . '/../Extensions/IXR_Library.php'; //for XML-RPC | |
//some code to drive browser with Selenium to get to LDAP login point | |
$client = new IXR_Client('http://localhost:8270/RPC2'); | |
if (!$client->query('run_keyword', 'LDAPLogin', array("yourUserName", "yourPassword"))) { | |
print 'An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage(); | |
} | |
/* now code that continues with Selenium after LDAP login completed | |
using custom AutoIt library (in Perl) served by RF Perl remote server | |
*/ | |
/* more complex example below utilizing AutoIt library server mentioned above | |
and Sikuli library in Java served via jrobotremoteserver 1.x | |
*/ | |
//some Selenium code to get to where we want to be first...then stuff to do non-browser UI automation: | |
$autoitClient = new IXR_Client('http://localhost:8270/RPC2'); | |
$sikuliClient = new IXR_Client('http://localhost:8271'); | |
print "\nSleep 30 sec for art file to open in Illustrator.\n"; | |
sleep(30); | |
print "\nNow switching to Illustrator window.\n"; | |
//switch to Illustrator window | |
if (!$autoitClient->query('run_keyword', 'activateIllustrator')){ | |
print 'An error occurred - '.$autoitClient->getErrorCode().":".$autoitClient->getErrorMessage(); | |
} | |
//verify opened art file before processing | |
if (!$sikuliClient->query('run_keyword', 'object_exists', array("img/artFileStart.png", 60))){ | |
print 'An error occurred - '.$sikuliClient->getErrorCode().":".$sikuliClient->getErrorMessage(); | |
} | |
$resp = $sikuliClient->getResponse(); | |
$this->assertEquals(true,$resp['return']); | |
print "\nVerified art file opened.\n"; | |
//run an Illustrator script against art file | |
if (!$autoitClient->query('run_keyword', 'runSomeillustratorScript')){ | |
print 'An error occurred - '.$autoitClient->getErrorCode().":".$autoitClient->getErrorMessage(); | |
} | |
print "\nSleep 30 sec for script to finish.\n"; | |
sleep(30); | |
if (!$sikuliClient->query('run_keyword', 'object_exists', array("img/artScriptCompletedState.png", 60))){ | |
print 'An error occurred - '.$sikuliClient->getErrorCode().":".$sikuliClient->getErrorMessage(); | |
} | |
$resp = $sikuliClient->getResponse(); | |
$this->assertEquals(true,$resp['return']); | |
print "\nVerified script ran successfully.\n"; | |
//test cleanup follows, as we've reached end of test | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment