Ejemplo n.º 1
1
 /** @test */
 public function sampleTest()
 {
     $page = $this->driver->get('http://slovicka.my');
     $this->assertContains('Slovicka', $page->getTitle());
     $username = $this->driver->findElement(WebDriverBy::name('_username'));
     $username->sendKeys('*****@*****.**');
 }
 /**
  * @dataProvider userLocations
  */
 public function testUserLocation($proxy, $expected)
 {
     $this->driver = $this->proxied($proxy);
     $this->driver->get($this->url);
     $search = $this->driver->findElement(WebDriverBy::id('user-city'));
     $this->assertContains($expected, $search->getText());
 }
 /**
  * Поиск продукта по названию и переход на страницу
  * @param  String $link_text
  * @return Page_Product
  */
 public function click_product_by_link_text($link_text)
 {
     $wait = new WebDriverWait($this->web_driver, 30);
     $wait->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::linkText($link_text)));
     $this->web_driver->findElement(WebDriverBy::linkText($link_text))->click();
     return new Page_Product($this->web_driver);
 }
Ejemplo n.º 4
0
 /**
  * @param  RemoteWebDriver $web_driver
  */
 function __construct(RemoteWebDriver $web_driver)
 {
     $this->web_driver = $web_driver;
     // Дожидаемся загрузки первого елемента
     $wait = new WebDriverWait($this->web_driver, 30);
     $wait->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::id('MainContent_Email')));
     $this->email = $this->web_driver->findElement(WebDriverBy::id('MainContent_Email'));
     $this->password = $this->web_driver->findElement(WebDriverBy::id('MainContent_Password'));
     $this->remember = $this->web_driver->findElement(WebDriverBy::id('MainContent_RememberMe'));
     $this->submit = $this->web_driver->findElement(WebDriverBy::name('ctl00$MainContent$ctl05'));
 }
Ejemplo n.º 5
0
 public function goToForm($link_text)
 {
     $this->webDriver->get($this->url);
     // Go Home first
     $link = $this->webDriver->findElement(WebDriverBy::linkText($link_text));
     $link->click();
 }
Ejemplo n.º 6
0
 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'));
 }
Ejemplo n.º 7
0
 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();
 }
Ejemplo n.º 8
0
 public function applicationRightsResponsibilities()
 {
     Automation::grabElementByCssSelector($this->webDriver, 'tr.even:nth-child(6) > td:nth-child(4) > a:nth-child(1) > span:nth-child(1)')->click();
     $this->assertEquals('Rights and Responsibilities | NAEYC AMS', $this->webDriver->getTitle());
     $this->webDriver->findElement(WebDriverBy::id('edit-field-rights-read-und'))->click();
     $this->webDriver->findElement(WebDriverBy::id('edit-field-rights-plan-und'))->click();
     $this->webDriver->findElement(WebDriverBy::id('edit-field-rights-verify-und'))->click();
     $this->webDriver->findElement(WebDriverBy::id('edit-field-checkbox-list-1-und'))->click();
     $this->webDriver->findElement(WebDriverBy::id('edit-field-checkbox-list-2-und'))->click();
     $this->webDriver->findElement(WebDriverBy::id('edit-field-text-signature-und-0-value'))->sendKeys('WD');
     $this->webDriver->findElement(WebDriverBy::id('edit-submit'))->click();
 }
 public function testRegisterNewUser()
 {
     //    $now = time();
     //    $this->clickRegisterLink();
     //    $elements_values = array(
     //        'edit-name' => $now,
     //        'edit-mail' => "$now@example.com",
     //        'edit-pass-pass1' => 'password',
     //        'edit-pass-pass2'=> 'password',
     //    );
     //    foreach ($elements_values as $key => $value) {
     //      $element = $this->webDriver->findElement(WebDriverBy::id($key));
     //      $element->clear()->sendKeys($value);
     //    }
     //    $submit = $this->webDriver->findElement(WebDriverBy::id('edit-submit'));
     //    $submit->click();
     $now = Automation::registerNewUser($this->webDriver);
     $messages = $this->webDriver->findElement(WebDriverBy::cssSelector('.messages'));
     $expected_text = 'Registration successful. You are now logged in.';
     $actual_text = $messages->getText();
     $this->assertContains($expected_text, $actual_text, 'Registration message');
 }
Ejemplo n.º 10
0
 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')));
 }
Ejemplo n.º 11
0
 /**
  * Инициализация select sizes что бы делать клик после обновления страницы с новым обьектом
  * @return WebDriverSelect
  */
 private function init_select_sizes()
 {
     return new WebDriverSelect($this->web_driver->findElement(WebDriverBy::id("MainContent_DDListSize")));
 }
Ejemplo n.º 12
0
 /**
  * Returns a given element by css selector
  * @param string $css_selector
  * @return RemoteWebElement
  */
 public function getElementBySelector($css_selector)
 {
     return self::$webDriver->findElement(\WebDriverBy::cssSelector($css_selector));
 }
Ejemplo n.º 13
0
 public static function find_element($type, $value)
 {
     return self::$webDriver->findElement(WebDriverBy::$type($value));
 }
Ejemplo n.º 14
0
 /**
  * @param  RemoteWebDriver $web_driver
  */
 public function __construct(RemoteWebDriver $web_driver)
 {
     $this->web_driver = $web_driver;
     $this->login = $this->web_driver->findElement(WebDriverBy::id('HeadLoginView_HeadLoginStatus'));
 }
Ejemplo n.º 15
0
 /**
  * @param string $selector
  * @return \RemoteWebElement
  */
 private function _getElement($selector)
 {
     return $this->_driver->findElement($this->_getWebDriverBy($selector));
 }
Ejemplo n.º 16
0
 public static function grabElementByCssSelector(RemoteWebDriver $webDriver, $cssSelector)
 {
     $webDriver->wait(10, 1500)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::cssSelector($cssSelector)));
     $element = $webDriver->findElement(WebDriverBy::cssSelector($cssSelector));
     return $element;
 }
<?php

// An example of using php-webdriver.
require_once 'php_webdriver/__init__.php';
// start Firefox
$host = 'http://172.31.17.231:8910/';
// this is the default
$capabilities = array(WebDriverCapabilityType::BROWSER_NAME => 'phantomjs', WebDriverCapabilityType::ACCEPT_SSL_CERTS => true, WebDriverCapabilityType::JAVASCRIPT_ENABLED => true);
$driver = new RemoteWebDriver($host, $capabilities);
// navigate to 'http://docs.seleniumhq.org/'
$session = $driver->get('http://booking.tigerair.com/Search.aspx');
// Search 'php' in the search box
$from = $driver->findElement(WebDriverBy::cssSelector('select[name="ControlGroupSearchView_AvailabilitySearchInputSearchVieworiginStation1"] option[value="SUB"]'));
$from->click();
$type = $driver->findElement(WebDriverBy::id('ControlGroupSearchView_AvailabilitySearchInputSearchView_OneWay'));
$type->click();
$destination = $driver->findElement(WebDriverBy::cssSelector('select[name="ControlGroupSearchView_AvailabilitySearchInputSearchViewdestinationStation1"] option[value="CGK"]'));
$destination->click();
$tgl = $driver->findElement(WebDriverBy::cssSelector('select[name="ControlGroupSearchView$AvailabilitySearchInputSearchView$DropDownListMarketDay1"] option[value="31"]'));
$tgl->sendKeys('31');
$driver->findElement(WebDriverBy::id('ControlGroupSearchView_ButtonSubmit'))->click();
// wait at most 10 seconds until at least one result is shown
$result = $driver->wait(10)->until(WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(WebDriverBy::className('altRowItem')));
$countresult = count($result);
$arr = array();
for ($i = 0; $i < $countresult; $i++) {
    $arr[$i] = $result[$i]->getText();
}
echo json_encode(array('jadwal' => $arr));
// close the Firefox
$driver->quit();