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 doTypeAt($target, $value) { $element = $this->webDriver->findElement($target)->click(); $element->clear(); $this->webDriver->getKeyboard()->sendKeys($value); }