public function testSearch() { $this->webDriver->get($this->url); // find search field by its id $search = $this->webDriver->findElement(WebDriverBy::xpath('html/body/div[1]/div[1]/div/div[2]/form/label')); $search->click(); // typing into field $this->webDriver->getKeyboard()->sendKeys('php-webdriver'); // pressing "Enter" $this->webDriver->getKeyboard()->pressKey(WebDriverKeys::ENTER); $firstResult = $this->webDriver->findElement(WebDriverBy::cssSelector('li.repo-list-item:nth-child(1) > h3:nth-child(2) > a:nth-child(1)')); $firstResult->click(); // we expect that facebook/php-webdriver was the first result $this->assertContains("php-webdriver", $this->webDriver->getTitle()); $this->assertEquals('https://github.com/facebook/php-webdriver', $this->webDriver->getCurrentURL()); $this->assertElementNotFound(WebDriverBy::className('avatar')); }
public function testSearch() { $this->webDriver->get($this->url); // find search field by its id $search = $this->webDriver->findElement(WebDriverBy::id('js-command-bar-field')); $search->click(); // typing into field $this->webDriver->getKeyboard()->sendKeys('php-webdriver'); // pressing "Enter" $this->webDriver->getKeyboard()->pressKey(WebDriverKeys::ENTER); $firstResult = $this->webDriver->findElement(WebDriverBy::cssSelector('li.public:nth-child(1) > h3:nth-child(3) > a:nth-child(1) > em:nth-child(2)')); $firstResult->click(); // we expect that facebook/php-webdriver was the first result $this->assertContains("php-webdriver", $this->webDriver->getTitle()); $this->assertEquals('https://github.com/facebook/php-webdriver', $this->webDriver->getCurrentURL()); $this->assertElementNotFound(WebDriverBy::className('avatar')); // $this->waitForUserInput(); }
public function _getCurrentUri() { $url = $this->webDriver->getCurrentURL(); $parts = parse_url($url); if (!$parts) $this->fail("URL couldn't be parsed"); $uri = ""; if (isset($parts['path'])) $uri .= $parts['path']; if (isset($parts['query'])) $uri .= "?".$parts['query']; if (isset($parts['fragment'])) $uri .= "#".$parts['fragment']; return $uri; }
/** * @param $start_time * The timestamp on the user ID we are modifying the program for * @param $time_change * $time parameter passed to strtotime */ public function adminChangeProgramVUD($start_time, $time_change) { $this->webDriver->get($this->url . '/admin/structure/entity-type/checklist/accredited'); Automation::grabElementByCssSelector($this->webDriver, '.pager-last > a:nth-child(1)')->click(); // Page to last page // And then all of this to wait for the list to refresh... $this->webDriver->wait(3, 500)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector('.pager-first'))); $link = $this->webDriver->findElement(WebDriverBy::linkText("Checklist Accredited | Webdriver Program {$start_time}")); $link->click(); $edit_url = $this->webDriver->getCurrentURL() . '/edit'; $this->webDriver->get($edit_url); $vud_box = Automation::grabElementByCssSelector($this->webDriver, '#edit-field-accreditation-valid-until-und-0-value-date'); $vud = $vud_box->getAttribute('value'); $vud_date = strtotime($vud); $minus1year = strtotime($time_change, $vud_date); $minus1year_text = date('M d Y', $minus1year); $vud_box->clear(); $vud_box->sendKeys($minus1year_text); $submit = Automation::grabElementByCssSelector($this->webDriver, '#edit-submit'); $submit->click(); }
public function doLogOutLogIn() { if ($this->_testMode < 0) { return; } $username = null; $password = null; $driver = $this->webDriver; $driver->get($this->url . "logout.php"); $driver->wait(15, 300)->until(function ($webDriver) { return $webDriver->getCurrentURL() === $this->url . 'index.php'; }); $indexURL = $this->url . 'index.php'; $currentURL = $this->webDriver->getCurrentURL(); $this->assertEquals($indexURL, $currentURL); if ($indexURL !== $currentURL) { $this->markTestSkipped('Logout page failed.'); return; } $this->assertEquals('PHP Job Seeker 2', $this->webDriver->getTitle()); $this->checkHeaderLoads(); try { $username = $this->webDriver->findElement(WebDriverBy::name('auth_username')); $password = $this->webDriver->findElement(WebDriverBy::name('auth_password')); } catch (NoSuchElementException $ex) { $this->markTestIncomplete('This part of the test has not been written.'); return; } $this->assertNotNull($username); $this->assertNotNull($password); if (null === $username || null === $password) { $this->markTestSkipped('Unable to test login screen - fields missing.'); return false; } $username->sendKeys($this->_userName); $password->sendKeys($this->_password)->submit(); $url = $this->webDriver->getCurrentURL(); $this->assertEquals($this->url . "index.php", $url); $this->assertEquals(true, $this->doWaitFor(WebDriverBy::linkText('Log Out'))); }
public function _getCurrentUri() { $url = $this->webDriver->getCurrentURL(); if ($url == 'about:blank') { throw new ModuleException($this, "Current url is blank, no page was opened"); } return Uri::retrieveUri($url); }
/** * @return string */ public function getPageUrl() { return $this->_driver->getCurrentURL(); }