/**
  * @test
  */
 public function 質問ページから質問投稿する()
 {
     //        $basic_user = '******';
     //        $basic_pass = '******';
     //        $gooid_user = '******';
     //        $gooid_pass = '******';
     //        $domain = '*****.goo.ne.jp';
     require __DIR__ . '/../config.php';
     $basic_user = urlencode($basic_user);
     $basic_pass = urlencode($basic_pass);
     $title = 'タイトル' . time();
     $description = '本文' . time();
     $driver = Util::createDriver();
     Util::loginToGoo($driver, $gooid_user, $gooid_pass);
     $driver->get("http://{$basic_user}:{$basic_pass}@{$domain}/question");
     $driver->findElement(\WebDriverBy::id('title_area'))->sendKeys($title);
     $driver->findElement(\WebDriverBy::id('text_area'))->sendKeys($description);
     $driver->findElement(\WebDriverBy::cssSelector('#question_confirm_btn > a > span.q-text'))->click();
     Util::skipPageLenvingAlert($driver);
     $driver->wait(5)->until(\WebDriverExpectedCondition::visibilityOfElementLocated(\WebDriverBy::cssSelector('#match_categories > input')));
     $driver->findElement(\WebDriverBy::cssSelector('#question_complete_button > a'))->click();
     $driver->findElement(\WebDriverBy::cssSelector('li.tooSeeBtn > a'))->click();
     $actual_title = $driver->getTitle();
     $url = $driver->getCurrentUrl();
     preg_match('/\\/qa\\/(\\d+)\\.html/', $url, $matches);
     $qid = $matches[1];
     $trimed_title = preg_replace('/ - .+/', '', $actual_title);
     echo $actual_title . "\n";
     echo $url . "\n";
     echo $qid . "\n";
     $driver->quit();
     $this->assertEquals($title, $trimed_title);
 }
 /**
  * Поиск продукта по названию и переход на страницу
  * @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);
 }
 /**
  * @param  RemoteWebDriver $web_driver
  */
 function __construct(RemoteWebDriver $web_driver)
 {
     $this->web_driver = $web_driver;
     // Дожидаемся загрузки первого елемента(кнопка Add to cart)
     $wait = new WebDriverWait($this->web_driver, 30);
     $wait->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::id('MainContent_btn_addToCart')));
     $this->colors = $this->init_select();
     $this->sizes = $this->init_select_sizes();
 }
Exemplo 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'));
 }
Exemplo n.º 5
0
 /**
  * Waits for element to be visible on the page for $timeout seconds to pass.
  * If element doesn't appear, timeout exception is thrown.
  *
  * ``` php
  * <?php
  * $I->waitForElementVisible('#agree_button', 30); // secs
  * $I->click('#agree_button');
  * ?>
  * ```
  *
  * @param $element
  * @param int $timeout seconds
  * @throws \Exception
  */
 public function waitForElementVisible($element, $timeout = 10)
 {
     $condition = null;
     if (Locator::isID($element)) {
         $condition = \WebDriverExpectedCondition::visibilityOfElementLocated(\WebDriverBy::id(substr($element, 1)));
     }
     if (!$condition and Locator::isCSS($element)) {
         $condition = \WebDriverExpectedCondition::visibilityOfElementLocated(\WebDriverBy::cssSelector($element));
     }
     if (Locator::isXPath($element)) {
         $condition = \WebDriverExpectedCondition::visibilityOfElementLocated(\WebDriverBy::xpath($element));
     }
     if (!$condition) {
         throw new \Exception("Only CSS or XPath allowed");
     }
     $this->webDriver->wait($timeout)->until($condition);
 }
Exemplo n.º 6
0
 /**
  * Waits up to $timeout seconds for the given element to be visible on the page.
  * If element doesn't appear, a timeout exception is thrown.
  *
  * ``` php
  * <?php
  * $I->waitForElementVisible('#agree_button', 30); // secs
  * $I->click('#agree_button');
  * ?>
  * ```
  *
  * @param $element
  * @param int $timeout seconds
  * @throws \Exception
  */
 public function waitForElementVisible($element, $timeout = 10)
 {
     $condition = \WebDriverExpectedCondition::visibilityOfElementLocated($this->getLocator($element));
     $this->webDriver->wait($timeout)->until($condition);
 }
Exemplo n.º 7
0
 /**
  * An expectation for checking an element is visible and enabled such that you
  * can click it.
  *
  * @param WebDriverBy $by The locator used to find the element
  * @return WebDriverExpectedCondition<WebDriverElement> The WebDriverElement
  *         once it is located, visible and clickable
  */
 public static function elementToBeClickable(WebDriverBy $by)
 {
     $visibility_of_element_located = WebDriverExpectedCondition::visibilityOfElementLocated($by);
     return new WebDriverExpectedCondition(function ($driver) use($visibility_of_element_located) {
         $element = call_user_func($visibility_of_element_located->getApply(), $driver);
         try {
             if ($element !== null && $element->isEnabled()) {
                 return $element;
             } else {
                 return null;
             }
         } catch (StaleElementReferenceException $e) {
             return null;
         }
     });
 }