Last active
August 29, 2015 14:13
-
-
Save klimesf/2ffa47a9a06dd326c8fe to your computer and use it in GitHub Desktop.
Nette\Tester + Facebook\Webdriver
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 | |
namespace Test\Presenters\AdminModule; | |
use Tester; | |
use Tester\Assert; | |
use DesiredCapabilities; | |
use RemoteWebDriver; | |
use WebDriverBy as By; | |
require __DIR__ . '/../../bootstrap.php'; | |
/** | |
* @package Test\Presenters\AdminModule | |
* @author Filip Klimes <[email protected]> | |
* @testCase | |
*/ | |
class SignPresenterSeleniumTest extends Tester\TestCase | |
{ | |
/** | |
* @var RemoteWebDriver | |
*/ | |
protected $webDriver; | |
public function setUp() | |
{ | |
$host = 'http://localhost:4444/wd/hub'; | |
$this->webDriver = RemoteWebDriver::create($host, DesiredCapabilities::firefox()); | |
} | |
public function tearDown() | |
{ | |
$this->webDriver->close(); | |
} | |
function testLoginLogout() | |
{ | |
$this->webDriver->get('http://nette-sandbox.local/sign/in'); | |
Assert::same('Sign in', $this->webDriver->getTitle()); | |
$username = $this->webDriver->findElement(By::cssSelector('#frm-signInForm-username')); | |
Assert::true($username->isDisplayed()); | |
Assert::true($username->isEnabled()); | |
$username->click()->sendKeys('admin'); | |
$password = $this->webDriver->findElement(By::cssSelector('#frm-signInForm-password')); | |
Assert::true($password->isDisplayed()); | |
Assert::true($password->isEnabled()); | |
$password->click()->sendKeys('pass'); | |
$submit = $this->webDriver->findElement(By::cssSelector('#frm-signInForm-send')); | |
Assert::true($submit->isDisplayed()); | |
Assert::true($submit->isEnabled()); | |
$submit->click(); | |
Assert::match('#admin/default#i', $this->webDriver->getCurrentURL()); | |
$logout = $this->webDriver->findElement(By::cssSelector('a#logout')); | |
Assert::true($logout->isDisplayed()); | |
$logout->click(); | |
Assert::match('#sign/in#i', $this->webDriver->getCurrentURL()); | |
} | |
} | |
(new SignPresenterSeleniumTest())->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment