public function logInAsUser($userReference)
 {
     $user = UserFixtures::$users[$userReference];
     $this->webDriver->get("http://127.0.0.1:8000");
     $this->webDriver->findElement(WebDriverBy::id('username'))->clear();
     $this->webDriver->findElement(WebDriverBy::id('username'))->click();
     $this->webDriver->getKeyboard()->sendKeys($user->getEmail());
     $this->webDriver->findElement(WebDriverBy::id('password'))->click();
     $this->webDriver->getKeyboard()->sendKeys("p4ssw0rd");
     $this->webDriver->getKeyboard()->pressKey(WebDriverKeys::ENTER);
 }
Beispiel #2
0
 public function testSearch()
 {
     $this->webDriver->get($this->url);
     $input = $this->webDriver->findElement(WebDriverBy::cssSelector('#lst-ib'));
     $input->sendKeys('yiiframework');
     $this->webDriver->getKeyboard()->pressKey(WebDriverKeys::ENTER);
     // waiting for google load ajax complete.
     sleep(2);
     $response = $this->webDriver->findElement(WebDriverBy::cssSelector('#ires div.srg div.g div.rc h3.r a'))->getText();
     sleep(3);
     $this->assertContains('Yii PHP Framework', $response);
 }
Beispiel #3
0
 public function testSearch()
 {
     $this->webDriver->get($this->url);
     $form = $this->webDriver->findElement(WebDriverBy::cssSelector('form.js-site-search-form'));
     $input = $form->findElement(WebDriverBy::cssSelector('input[type=text].js-site-search-focus'));
     $input->sendKeys('yii 1.1');
     $form->submit();
     $link = $this->webDriver->findElement(WebDriverBy::cssSelector('ul.repo-list li.repo-list-item h3.repo-list-name a'));
     $link->click();
     $repositoryMeta = $this->webDriver->findElement(WebDriverBy::cssSelector('span.repository-meta-content'))->getText();
     sleep(3);
     $this->assertContains('Yii PHP Framework 1.1', $repositoryMeta);
 }
Beispiel #4
0
 /**
  * Set user agent
  */
 public function testSetUserAgent()
 {
     $useragent = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16';
     // setup
     $capabilities = DesiredCapabilities::firefox();
     /** @var FirefoxProfile $profile */
     $profile = $capabilities->getCapability(FirefoxDriver::PROFILE);
     $profile->setPreference('general.useragent.override', $useragent);
     $this->webDriver = RemoteWebDriver::create('http://' . self::HOST . '/wd/hub', $capabilities);
     // test
     $this->webDriver->get('http://demo.mobiledetect.net/');
     $elements = $this->webDriver->findElements(WebDriverBy::tagName('h1'));
     static::assertEquals(3, count($elements));
     $elementContainingQuestion = $elements[1];
     static::assertEquals('Is your device really a phone?', $elementContainingQuestion->getText());
     $this->webDriver->quit();
 }
Beispiel #5
0
 public function run()
 {
     if ($this->remoteWebDriver === null) {
         $this->remoteWebDriver = RemoteWebDriver::create('http://127.0.0.1:8910', DesiredCapabilities::phantomjs());
     }
     $script = '';
     $script .= file_get_contents(__DIR__ . '/js/jquery-2.2.2.min.js');
     $script .= "\n\n";
     $script .= file_get_contents(__DIR__ . '/js/frontendscraper.js');
     $script .= "\n\n";
     while ($job = $this->jobBuffer->getJob()) {
         $status = $this->createInitStatus($job);
         $this->remoteWebDriver->get($job->url);
         $inject = $script;
         $inject .= file_get_contents($this->jobScriptDir . '/' . $job->script);
         $inject .= "\n\n return phantomScraper.getResult();";
         $res = $this->remoteWebDriver->executeScript($inject);
         $this->addJobs($res['jobs']);
         $this->addData($res['data']);
         $this->updateStatus($status);
     }
 }
Beispiel #6
0
 public function amOnPage($page)
 {
     $url = Uri::appendPath($this->config['url'], $page);
     $this->debugSection('GET', $url);
     $this->webDriver->get($url);
 }
Beispiel #7
0
 public function getUrl(Url $url)
 {
     return $this->webDriver->get((string) $url);
 }
Beispiel #8
0
 public static function visit($path)
 {
     self::$webDriver->get(self::$root_url . $path);
 }
 public function testGitHubHome()
 {
     $this->webDriver->get($this->url);
     self::assertContains('GitHub', $this->webDriver->getTitle());
 }