Created
May 22, 2015 10:31
-
-
Save omeraslam-vteams/4b19c14e70db107b5620 to your computer and use it in GitHub Desktop.
Configuring the profile and firebug with test cases
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 | |
class BrowserFactory { | |
private $user_agent = ''; | |
/** | |
* @return static | |
*/ | |
public static function factory() { | |
switch ($_SERVER['BROWSER_REQUESTED']) { | |
case 'safari': | |
return self::createSafari(); | |
break; | |
case 'chrome': | |
return self::createChrome(); | |
break; | |
case "ie": | |
return self::createIE(); | |
break; | |
case 'firefox': | |
default: | |
return self::createFirefox(); | |
break; | |
} | |
} | |
/** | |
* @return RemoteWebDriver | |
*/ | |
public static function createFirefox() { | |
// these are just constants defined in bootstrap.php | |
if (empty(preg_grep("/^localhost/", $_SERVER['HTTP_HOST']))) { | |
$seleniumUrl = SELENIUM_LIVE_URL; | |
} else { | |
$seleniumUrl = SELENIUM_LOCAL_URL; | |
} | |
return RemoteWebDriver::create( | |
$seleniumUrl, DesiredCapabilities::firefox(), 5000 | |
); | |
} | |
public static function createSafari() { | |
} | |
} |
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 | |
/** | |
* Class SampleTest | |
* DESCRIPTION : | |
* Test that a learner can see and download files | |
* | |
* var $uid id of the test academy owner | |
*/ | |
class SampleTest extends TestConfigs | |
{ | |
/** | |
* @BeforeMethod | |
* SETUP METHOD TO ADD TEST DATA AND INITALIZE THE REMOTEWEBDRIVERS | |
*/ | |
protected function setUp() | |
{ | |
try { | |
/*INITI BROWSER*/ | |
$this->setupBrowser(); | |
} catch (Exception $e) { | |
echo $e->getMessage(); | |
} | |
} | |
/** | |
* @AfterMethod | |
* TEAR DOWN METHOD TO REMOVE TEST DATA AND CLOSE THE WEBDRIVER INSTANCE | |
*/ | |
public function tearDown() | |
{ | |
//REMOVE ALL TEST DATA | |
$this->tearDownData(); | |
/*CLOSE THE WEBDRIVERS*/ | |
$this->driver->close(); | |
$this->driver->quit(); | |
} | |
/** | |
* FUNCTION:testCourseDownloadablesStudent | |
* Test that a learner can see and download files | |
*/ | |
public function testTestCase() | |
{ | |
$errorSnaps = ''; | |
$myBrowserDriver = $this->driver; | |
//open the url | |
$myBrowserDriver->get(base_url()); | |
//maximize window | |
$myBrowserDriver->manage()->window()->maximize(); | |
} | |
/** | |
* Function : tearDownData | |
* Description: REMOVE ALL TEST DATA FROM THE DATABASE | |
*/ | |
protected function tearDownData() | |
{ | |
//your tear down code for removing the test data | |
} | |
} |
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 | |
/** | |
* Class TestConfigs | |
* DESCRIPTION : | |
* BASE CLASS FOR TESTS AND | |
* CONFIG VARIABLES FOR TESTING ENVIRONEMNT | |
* | |
* var $driver instance of the REMOTE WEB DRIVER | |
* var $error_logs array() stores the errors /exceptions that fail the test | |
* var $screenShotDirectoryPath path for saving snapshots | |
* var $testVideoImage image for video poster | |
* var $testVideoImageDirectory path sources for test images & videos | |
* var $testVideoFile name for the test course teaser video | |
* var $assetsPathMedia path media assets upload directory; | |
* var $CI instance of codeignter framework | |
* var $uid id of the test academy owner | |
* var $testUserName username for login | |
* var $testUserPass password for the login | |
*/ | |
abstract class TestConfigs extends PHPUnit_Framework_TestCase{ | |
protected $cleanUpScreenshotDirectory = true; | |
protected $showErrorLogs = FALSE; | |
protected $driver; | |
protected $errorLogs = array(); | |
protected $CI; | |
function __construct(){ | |
/*GET INSTANCE OF CI*/ | |
$this->CI = &get_instance(); | |
} | |
/** | |
* Function : | |
* GET BROWSER FACTORY OBJECT FOR SELENIUM | |
*/ | |
protected function setupBrowser(){ | |
/*INIT REMOTE WEBDRIVER FOR SELENIUM*/ | |
$this->driver = BrowserFactory::factory(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment