Skip to content

Commit

Permalink
Dev: Subclass Facebook web driver to LimeSurveyWebDriver
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jan 17, 2018
1 parent 004e4fa commit f94d21d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
42 changes: 42 additions & 0 deletions tests/LimeSurveyWebDriver.php
@@ -0,0 +1,42 @@
<?php

namespace ls\tests;

use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\WebDriverBy;

/**
* Subclass of Facebook webdriver.
* This class contains helper methods to interact with a LimeSurvey
* survey, like filling in questions, going to next question group,
* changing language etc.
*/
class LimeSurveyWebDriver extends RemoteWebDriver
{
/**
* @param string $newLang Like 'de' or 'en'.
* @return void
*/
public function changeLanguage($newLang)
{
$langSelectOption = $this->findElement(
WebDriverBy::cssSelector(
sprintf(
'#langchangerSelectMain option[value="%s"]',
$newLang
)
)
);
$langSelectOption->click();
}

/**
* Go to next question/question group.
* @return void
*/
public function next()
{
$nextButton = $this->findElement(WebDriverBy::id('ls-button-submit'));
$nextButton->click();
}
}
2 changes: 1 addition & 1 deletion tests/TestBaseClassWeb.php
Expand Up @@ -32,7 +32,7 @@ class TestBaseClassWeb extends TestBaseClass
public static $webPort = 4444;

/**
* @var WebDriver $webDriver
* @var LimeSurveyWebDriver $webDriver
*/
protected static $webDriver;

Expand Down
2 changes: 1 addition & 1 deletion tests/TestHelper.php
Expand Up @@ -397,7 +397,7 @@ public function getWebDriver()
// Open target="_blank" in new tab.
$profile->setPreference('browser.link.open_newwindow', 3);
$capabilities->setCapability(FirefoxDriver::PROFILE, $profile);
$webDriver = RemoteWebDriver::create($host, $capabilities, 5000);
$webDriver = LimeSurveyWebDriver::create($host, $capabilities, 5000);
$success = true;
} catch (WebDriverException $ex) {
$tries++;
Expand Down
1 change: 1 addition & 0 deletions tests/bootstrap.php
Expand Up @@ -224,6 +224,7 @@
throw new ErrorException($msg, 0, $no, $file, $line);
}, E_ERROR & E_WARNING & E_PARSE & E_NOTICE);

require_once(__DIR__ . '/LimeSurveyWebDriver.php');
require_once(__DIR__ . '/TestHelper.php');
require_once(__DIR__ . '/TestBaseClass.php');
require_once(__DIR__ . '/TestBaseClassWeb.php');
Expand Down

0 comments on commit f94d21d

Please sign in to comment.