Ejemplo n.º 1
1
 public function testWithoutMagium()
 {
     // This test is based off of my own test environment and so everything up until the Twitter authentication will
     // not work.  So ignore the first part.
     $webDriver = RemoteWebDriver::create('http://*****:*****@data-strategy="twitter"]'));
     $webDriver->wait()->until(ExpectedCondition::visibilityOf($element));
     $element->click();
     // Start from here
     $configurationProvider = new StandardConfigurationProvider(new ConfigurationReader(), new ClassConfigurationReader(), new EnvironmentConfigurationReader());
     $collector = new DefaultPropertyCollector();
     $action = new AuthenticateTwitter($webDriver, new \Magium\Twitter\Themes\Twitter($configurationProvider, $collector), new Twitter($configurationProvider, $collector));
     $action->execute();
     $webDriver->quit();
 }
Ejemplo n.º 2
0
 public function extract()
 {
     if (!$this->nodePath) {
         throw new InvalidInstructionException('Node path was not specified');
     }
     $parts = explode('/', $this->nodePath);
     $xpath = $this->theme->getXTreeRootXpath();
     if ($this->rootCategory) {
         $xpath = $this->theme->getXTreeNamedRootXpath($this->rootCategory);
     }
     $xpath .= $this->theme->getXTreeChildNodePrefixXpath();
     $previousExpandXpath = '';
     $element = null;
     foreach ($parts as $part) {
         $xpath .= '/' . $this->theme->getXTreeChildXpath($part);
         if (!$this->webDriver->elementExists($xpath, WebDriver::BY_XPATH)) {
             if ($previousExpandXpath) {
                 $this->testCase->assertElementExists($previousExpandXpath, WebDriver::BY_XPATH);
                 $this->webDriver->byXpath($previousExpandXpath)->click();
                 $this->webDriver->wait()->until(ExpectedCondition::elementExists($xpath, WebDriver::BY_XPATH));
                 $this->testCase->sleep('1s');
                 // Give the menu time to render
             }
         }
         $this->testCase->assertElementExists($xpath, WebDriver::BY_XPATH);
         $element = $this->webDriver->byXpath($xpath);
         if (!$element->isDisplayed()) {
             throw new ElementNotVisibleException('Node element is not visible and cannot be made visible: ' . $part);
         }
         $previousExpandXpath = $xpath . $this->theme->getXTreeChildNodeExpandPrefixXpath();
         $xpath .= $this->theme->getXTreeChildNodePrefixXpath();
     }
     $this->node = $element;
 }
Ejemplo n.º 3
0
 public function nextAction()
 {
     $button = $this->webdriver->byXpath($this->theme->getCustomerButtonXpath());
     $button->click();
     $this->webdriver->wait()->until(ExpectedCondition::elementExists($this->theme->getBillingFirstNameXpath(), AbstractTestCase::BY_XPATH));
     return true;
 }
Ejemplo n.º 4
0
 public function login($username = null, $password = null)
 {
     // We break SOLID here there might be scenarios where multiple logins are required.  So for expediency's sake
     // We're having the login action take responsibility for figuring out how to get to the login screen.
     $url = $this->webdriver->getCurrentURL();
     if (strpos($url, 'http') === false) {
         $this->openCommand->open($this->theme->getBaseUrl());
     } else {
         $this->webdriver->navigate()->to($this->theme->getBaseUrl());
         $title = $this->webdriver->getTitle();
         if (strpos($title, $this->testCase->getTranslator()->translate('Dashboard')) !== false) {
             return;
         }
     }
     $usernameElement = $this->webdriver->byXpath($this->theme->getLoginUsernameField());
     $passwordElement = $this->webdriver->byXpath($this->theme->getLoginPasswordField());
     $submitElement = $this->webdriver->byXpath($this->theme->getLoginSubmitButton());
     $this->testCase->assertWebDriverElement($usernameElement);
     $this->testCase->assertWebDriverElement($passwordElement);
     $this->testCase->assertWebDriverElement($submitElement);
     if ($username === null) {
         $username = $this->adminIdentity->getAccount();
     }
     if ($password === null) {
         $password = $this->adminIdentity->getPassword();
     }
     $usernameElement->clear();
     $passwordElement->clear();
     $usernameElement->sendKeys($username);
     $passwordElement->sendKeys($password);
     $submitElement->click();
     $this->webdriver->wait()->until(ExpectedCondition::titleContains($this->testCase->getTranslator()->translate('Dashboard')));
     $this->messages->extract();
 }
Ejemplo n.º 5
0
    public function testWaitUntilElementIsRemoved()
    {
        $script = <<<SCRIPT
<html><script>
setTimeout(
    function(){
        document.getElementById('test').removeChild(document.getElementById('a'));
    },
    2000
);
</script>
<body>
<div id="test"><div id="a">test</div></div>
</body>
</html>
SCRIPT;
        $filename = tempnam(sys_get_temp_dir(), 'test');
        $fh = fopen($filename, 'w+');
        fwrite($fh, $script);
        fclose($fh);
        chmod($filename, 0666);
        $this->commandOpen('file://' . $filename);
        unlink($filename);
        $element = $this->webdriver->byId('a');
        $this->webdriver->wait()->until(ExpectedCondition::elementRemoved($element));
        $this->assertElementNotExists('a');
    }
 public function nextAction()
 {
     $this->webdriver->wait()->until(ExpectedCondition::elementExists($this->theme->getShippingMethodContinueButtonXpath(), WebDriver::BY_XPATH));
     $this->webdriver->wait()->until(ExpectedCondition::visibilityOf($this->webdriver->byXpath($this->theme->getShippingMethodContinueButtonXpath())));
     $this->webdriver->byXpath($this->theme->getShippingMethodContinueButtonXpath())->click();
     $this->webdriver->wait()->until(WebDriverExpectedCondition::not(WebDriverExpectedCondition::visibilityOf($this->webdriver->byXpath($this->theme->getShippingMethodContinueCompletedXpath()))));
     return true;
 }
Ejemplo n.º 7
0
 public function execute()
 {
     $this->webdriver->wait()->until(ExpectedCondition::elementExists($this->theme->getShippingMethodContinueButtonXpath(), WebDriver::BY_XPATH));
     $this->webdriver->wait()->until(ExpectedCondition::visibilityOf($this->webdriver->byXpath($this->theme->getShippingMethodContinueButtonXpath())));
     $this->shipping->choose($this->requireShipping);
     return true;
     // continue to next step
 }
Ejemplo n.º 8
0
 public function register($registerForNewsletter = false)
 {
     $this->navigator->navigateTo();
     $this->form->execute($registerForNewsletter);
     $submitElement = $this->webdriver->byXpath($this->theme->getRegisterSubmitXpath());
     $submitElement->click();
     $this->webdriver->wait()->until(ExpectedCondition::titleIs($this->theme->getMyAccountTitle()));
 }
Ejemplo n.º 9
0
 public function assert()
 {
     $by = $this->getTestCase()->filterWebDriverAction($this->by);
     try {
         $this->webDriver->wait(1)->until(ExpectedCondition::elementToBeClickable(WebDriverBy::$by($this->selector)));
     } catch (\Exception $e) {
         $this->getTestCase()->fail(sprintf('The element %s, located with %s, cannot be clicked', $this->selector, $by));
     }
 }
 public function execute()
 {
     $this->webdriver->wait()->until(ExpectedCondition::elementExists($this->theme->getGuestCheckoutButtonXpath(), AbstractTestCase::BY_XPATH));
     $this->testCase->assertElementDisplayed($this->theme->getGuestCheckoutButtonXpath(), AbstractTestCase::BY_XPATH);
     $element = $this->webdriver->byXpath($this->theme->getGuestCheckoutButtonXpath());
     $this->testCase->assertWebDriverElement($element);
     $element->click();
     return true;
 }
Ejemplo n.º 11
0
 public function execute(WebDriverElement $testElement = null)
 {
     if ($testElement instanceof WebDriverElement) {
         $this->webDriver->wait()->until(ExpectedCondition::elementRemoved($testElement));
     }
     $this->webDriver->wait()->until(ExpectedCondition::elementExists($this->theme->getGuaranteedPageLoadedElementDisplayedXpath(), WebDriver::BY_XPATH));
     $element = $this->webDriver->byXpath($this->theme->getGuaranteedPageLoadedElementDisplayedXpath());
     $this->webDriver->wait()->until(ExpectedCondition::visibilityOf($element));
 }
Ejemplo n.º 12
0
 public function assert()
 {
     $by = $this->getTestCase()->filterWebDriverAction($this->by);
     try {
         $this->webDriver->wait(1)->until(ExpectedCondition::elementToBeClickable(WebDriverBy::$by($this->selector)));
         $this->getTestCase()->fail(sprintf('The element %s, located with %s, is clickable but should not be', $this->selector, $by));
     } catch (\Exception $e) {
         // A failure is what we are hoping for.  It indicates that the element is not clickable, just like what the class wants
     }
 }
Ejemplo n.º 13
0
 public function save()
 {
     $this->webDriver->executeScript('window.scrollTo(0, 0);');
     $this->webDriver->wait()->until(ExpectedCondition::elementExists($this->adminThemeConfiguration->getSystemConfigurationSaveButtonXpath(), AbstractTestCase::BY_XPATH));
     $this->testCase->assertElementDisplayed($this->adminThemeConfiguration->getSystemConfigurationSaveButtonXpath(), AbstractTestCase::BY_XPATH);
     $element = $this->webDriver->byXpath($this->adminThemeConfiguration->getSystemConfigurationSaveButtonXpath());
     $element->click();
     $this->webDriver->wait()->until(ExpectedCondition::elementRemoved($element));
     $this->testCase->assertElementDisplayed($this->adminThemeConfiguration->getSystemConfigSaveSuccessfulXpath(), WebDriver::BY_XPATH);
 }
 public function execute()
 {
     if (!$this->customer->isUniqueEmailAddressGenerated()) {
         $this->customer->generateUniqueEmailAddress();
     }
     $this->webdriver->wait()->until(ExpectedCondition::elementExists($this->theme->getRegisterNewCustomerCheckoutButtonXpath(), AbstractTestCase::BY_XPATH));
     $element = $this->webdriver->byXpath($this->theme->getRegisterNewCustomerCheckoutButtonXpath());
     $this->testCase->assertWebDriverElement($element);
     $element->click();
     return true;
 }
Ejemplo n.º 15
0
 /**
  * Navigates to the section of the account management based off the section provided.  IF the header value is provided
  * it will issue a wait() command until the proper page header exists before returning.  This takes into account
  * the possibility of a section being loaded by Ajax while also retaining compatibility with templates based off
  * of the core template
  *
  * @param $section
  * @param null $header The title of the page
  */
 public function navigateTo($section, $header = null)
 {
     $xpath = $this->themeConfiguration->getAccountNavigationXpath($section);
     $element = $this->webDriver->byXpath($xpath);
     $element->click();
     $this->loader->execute($element);
     if ($header !== null) {
         $xpath = $this->themeConfiguration->getAccountSectionHeaderXpath($header);
         $this->webDriver->wait()->until(ExpectedCondition::elementExists($xpath, WebDriver::BY_XPATH));
     }
 }
Ejemplo n.º 16
0
 public function execute()
 {
     $this->webdriver->wait(10)->until(ExpectedCondition::elementExists($this->theme->getPaymentMethodContinueButtonXpath(), WebDriver::BY_XPATH));
     $element = $this->webdriver->byXpath($this->theme->getPaymentMethodContinueButtonXpath());
     $this->webdriver->wait(5)->until(ExpectedCondition::visibilityOf($element));
     /* Given that there is the possibility of either a) products with $0, and b) payment methods that do not use
      * the standard form we do not fail if we cannot find payment elements
      */
     $this->paymentMethod->pay($this->requirePayment);
     return true;
 }
Ejemplo n.º 17
0
 /**
  * @param array $instructions
  * @throws ElementNotVisibleException
  * @throws InvalidConfigurationException
  * @throws \Facebook\WebDriver\Exception\NoSuchElementException
  * @throws \Facebook\WebDriver\Exception\TimeOutException
  */
 public function navigateTo(array $instructions)
 {
     $this->testCase->assertGreaterThan(0, count($instructions), 'Instruction navigator requires at least one instruction');
     $useAutomaticTiming = true;
     foreach ($instructions as $key => $instruction) {
         if (count($instruction) > 0 && $instruction[0] == self::INSTRUCTION_USE_MANUAL_TIMING) {
             $useAutomaticTiming = false;
         }
     }
     foreach ($instructions as $instruction) {
         $this->testCase->assertCount(2, $instruction, 'Navigation instructions need to be a 2 member array.  First item is the instruction type, the second is the XPath');
         list($instruction, $xpath) = $instruction;
         if ($useAutomaticTiming) {
             $this->testCase->sleep('100ms');
             // Courtesy sleep of 100ms
             if ($instruction == self::INSTRUCTION_MOUSE_MOVETO || $instruction == self::INSTRUCTION_MOUSE_CLICK) {
                 $this->webdriver->wait()->until(ExpectedCondition::elementExists($xpath, WebDriver::BY_XPATH));
                 $this->webdriver->wait(5)->until(ExpectedCondition::elementToBeClickable(WebDriverBy::xpath($xpath)));
             }
         }
         switch ($instruction) {
             case self::INSTRUCTION_MOUSE_CLICK:
                 $element = $this->webdriver->byXpath($xpath);
                 if (!$element->isDisplayed()) {
                     throw new ElementNotVisibleException('The element is not visible: ' . $xpath);
                 }
                 $element->click();
                 break;
             case self::INSTRUCTION_MOUSE_MOVETO:
                 $element = $this->webdriver->byXpath($xpath);
                 $this->webdriver->getMouse()->mouseMove($element->getCoordinates());
                 break;
             case self::INSTRUCTION_WAIT_FOR_EXISTS:
                 $this->webdriver->wait()->until(ExpectedCondition::elementExists($xpath, WebDriver::BY_XPATH));
                 break;
             case self::INSTRUCTION_WAIT_FOR_NOT_EXISTS:
                 $this->webdriver->wait()->until(ExpectedCondition::not(ExpectedCondition::elementExists($xpath, WebDriver::BY_XPATH)));
                 break;
             case self::INSTRUCTION_WAIT_FOR_DISPLAYED:
                 $element = $this->webdriver->byXpath($xpath);
                 $this->webdriver->wait()->until(ExpectedCondition::visibilityOf($element));
                 break;
             case self::INSTRUCTION_PAUSE:
                 $this->testCase->sleep($xpath);
                 break;
             case self::INSTRUCTION_WAIT_FOR_HIDDEN:
                 $element = $this->webdriver->byXpath($xpath);
                 $this->webdriver->wait()->until(ExpectedCondition::not(ExpectedCondition::visibilityOf($element)));
                 break;
             default:
                 throw new InvalidConfigurationException('Unknown login instruction: ' . $instruction);
         }
     }
 }
Ejemplo n.º 18
0
 public function navigateTo($orderId)
 {
     $xpath = $this->themeConfiguration->getAccountNavigationXpath($this->themeConfiguration->getOrderPageName());
     $element = $this->webDriver->byXpath($xpath);
     $element->click();
     $this->loaded->execute($element);
     $xpath = $this->themeConfiguration->getViewOrderLinkXpath($orderId);
     $element = $this->webDriver->byXpath($xpath);
     $element->click();
     $this->loaded->execute($element);
     $this->webDriver->wait()->until(ExpectedCondition::titleContains($this->themeConfiguration->getOrderPageTitleContainsText()));
 }
 public function execute()
 {
     if ($this->enterNewAddress) {
         $this->webdriver->wait()->until(ExpectedCondition::visibilityOf($this->webdriver->byXpath($this->theme->getShippingNewAddressXpath())));
         $this->webdriver->byXpath($this->theme->getShippingNewAddressXpath())->click();
         $this->webdriver->wait()->until(ExpectedCondition::visibilityOf($this->webdriver->byXpath($this->theme->getShippingFirstNameXpath())));
     }
     // We will bypass ourself if the billing address is the same as the shipping address.
     if (!$this->webdriver->elementDisplayed($this->theme->getShippingFirstNameXpath(), AbstractTestCase::BY_XPATH)) {
         $this->bypassNextStep = true;
         return true;
     }
     // assertions
     $this->testCase->assertElementExists($this->theme->getShippingFirstNameXpath(), WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingLastNameXpath(), WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingCompanyXpath(), WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingAddressXpath(), WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingAddress2Xpath(), WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingCityXpath(), WebDriver::BY_XPATH);
     $regionXpath = $this->theme->getShippingRegionIdXpath($this->customerIdentity->getShippingRegionId());
     $this->testCase->assertElementExists($regionXpath, WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingPostCodeXpath(), WebDriver::BY_XPATH);
     $countryXpath = $this->theme->getShippingCountryIdXpath($this->customerIdentity->getShippingCountryId());
     $this->testCase->assertElementExists($countryXpath, WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingTelephoneXpath(), WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingFaxXpath(), WebDriver::BY_XPATH);
     $this->testCase->assertElementExists($this->theme->getShippingContinueButtonXpath(), WebDriver::BY_XPATH);
     // clear
     $this->testCase->byXpath($this->theme->getShippingFirstNameXpath())->clear();
     $this->testCase->byXpath($this->theme->getShippingLastNameXpath())->clear();
     $this->testCase->byXpath($this->theme->getShippingCompanyXpath())->clear();
     $this->testCase->byXpath($this->theme->getShippingAddressXpath())->clear();
     $this->testCase->byXpath($this->theme->getShippingAddress2Xpath())->clear();
     $this->testCase->byXpath($this->theme->getShippingCityXpath())->clear();
     $this->testCase->byXpath($this->theme->getShippingPostCodeXpath())->clear();
     $this->testCase->byXpath($this->theme->getShippingTelephoneXpath())->clear();
     $this->testCase->byXpath($this->theme->getShippingFaxXpath())->clear();
     // execute
     $this->testCase->byXpath($this->theme->getShippingFirstNameXpath())->sendKeys($this->customerIdentity->getShippingFirstName());
     $this->testCase->byXpath($this->theme->getShippingLastNameXpath())->sendKeys($this->customerIdentity->getShippingLastName());
     $this->testCase->byXpath($this->theme->getShippingCompanyXpath())->sendKeys($this->customerIdentity->getShippingCompany());
     $this->testCase->byXpath($this->theme->getShippingAddressXpath())->sendKeys($this->customerIdentity->getShippingAddress());
     $this->testCase->byXpath($this->theme->getShippingAddress2Xpath())->sendKeys($this->customerIdentity->getShippingAddress2());
     $this->testCase->byXpath($this->theme->getShippingCityXpath())->sendKeys($this->customerIdentity->getShippingCity());
     $regionXpath = $this->theme->getShippingRegionIdXpath($this->customerIdentity->getShippingRegionId());
     $this->testCase->byXpath($regionXpath)->click();
     $this->testCase->byXpath($this->theme->getShippingPostCodeXpath())->sendKeys($this->customerIdentity->getShippingPostCode());
     $countryXpath = $this->theme->getShippingCountryIdXpath($this->customerIdentity->getShippingCountryId());
     $this->testCase->byXpath($countryXpath)->click();
     $this->testCase->byXpath($this->theme->getShippingTelephoneXpath())->sendKeys($this->customerIdentity->getShippingTelephone());
     $this->testCase->byXpath($this->theme->getShippingFaxXpath())->sendKeys($this->customerIdentity->getShippingFax());
     return true;
 }
Ejemplo n.º 20
0
 public function choose($required)
 {
     $this->webDriver->wait()->until(ExpectedCondition::elementExists($this->theme->getShippingMethodFormXpath(), AbstractTestCase::BY_XPATH));
     // Some products, such as virtual products, do not get shipped
     if ($required) {
         $this->testCase->assertElementExists($this->theme->getDefaultShippingXpath(), AbstractTestCase::BY_XPATH);
         $this->testCase->assertElementDisplayed($this->theme->getDefaultShippingXpath(), AbstractTestCase::BY_XPATH);
     }
     if ($this->webDriver->elementDisplayed($this->theme->getDefaultShippingXpath(), AbstractTestCase::BY_XPATH)) {
         $this->webDriver->byXpath($this->theme->getDefaultShippingXpath())->click();
     }
 }
Ejemplo n.º 21
0
 public function execute()
 {
     $element = $this->webDriver->byId('a0-signin_easy_email');
     $element->clear();
     $element->sendKeys($this->username);
     $element = $this->webDriver->byId('a0-signin_easy_password');
     $element->clear();
     $element->sendKeys($this->password);
     $body = $this->webDriver->byXpath('//body');
     $element = $this->webDriver->byXpath('//div[@class="a0-action"]/button');
     $element->click();
     $this->webDriver->wait()->until(ExpectedCondition::elementRemoved($body));
 }
Ejemplo n.º 22
0
 public function navigateTo($path)
 {
     $paths = explode('/', $path);
     $xpath = $this->themeConfiguration->getNavigationBaseXPathSelector();
     $this->webdriver->wait()->until(ExpectedCondition::visibilityOf($this->webdriver->byXpath($xpath)));
     $element = null;
     foreach ($paths as $p) {
         $element = $this->pathAction($p, $xpath);
     }
     if (!$this->themeConfiguration->getUseClicksToNavigate() && $element instanceof WebDriverElement) {
         $element->click();
         $this->loaded->execute($element);
     }
 }
 protected function clickAddToCart()
 {
     $element = $this->addToCart->getElement();
     // Because, for some reason, the M2 design HIDES the add-to-cart button as part of the default theme.   Why
     // would you want to hide the second most important button on the site?
     try {
         $element->click();
     } catch (\Exception $e) {
         $e2 = $this->webDriver->byXpath($this->theme->getAddToCartXpath() . '/ancestor::li');
         $this->webDriver->getMouse()->mouseMove($e2->getCoordinates());
         $element->click();
     }
     $this->webDriver->wait()->until(ExpectedCondition::elementExists($this->theme->getAddToCartSuccessXpath(), WebDriver::BY_XPATH));
 }
Ejemplo n.º 24
0
 protected function preExecute()
 {
     if ($this->enterNewAddress) {
         $this->webdriver->wait()->until(ExpectedCondition::visibilityOf($this->webdriver->byXpath($this->theme->getShippingNewAddressXpath())));
         $this->webdriver->byXpath($this->theme->getShippingNewAddressXpath())->click();
         $this->webdriver->wait()->until(ExpectedCondition::visibilityOf($this->webdriver->byXpath($this->theme->getShippingFirstNameXpath())));
     }
     // We will bypass ourself if the billing address is the same as the shipping address.
     if (!$this->webdriver->elementDisplayed($this->theme->getShippingFirstNameXpath(), AbstractTestCase::BY_XPATH)) {
         $this->bypassNextStep = true;
         return true;
     }
     return false;
 }
 public function extract()
 {
     $testXpath = $this->theme->getSearchSuggestionTextXpath(1);
     $this->webDriver->wait(5)->until(ExpectedCondition::elementExists($testXpath, WebDriver::BY_XPATH));
     $testElement = $this->webDriver->byXpath($testXpath);
     $this->webDriver->wait(5)->until(ExpectedCondition::visibilityOf($testElement));
     $count = 0;
     $this->suggestions = [];
     while ($this->webDriver->elementExists($this->theme->getSearchSuggestionTextXpath(++$count), WebDriver::BY_XPATH)) {
         $suggestionCount = trim($this->webDriver->byXpath($this->theme->getSearchSuggestionCountXpath($count))->getText());
         $suggestionText = trim($this->webDriver->byXpath($this->theme->getSearchSuggestionTextXpath($count))->getText());
         $suggestionText = trim($suggestionText, $suggestionCount);
         $this->suggestions[] = new SearchSuggestion($this->webDriver->byXpath($this->theme->getSearchSuggestionTextXpath($count)), $suggestionCount, $suggestionText);
     }
 }
Ejemplo n.º 26
0
 public function extract()
 {
     $productIterator = new ProductIterator();
     $this->values[self::VALUE_PRODUCTS] = $productIterator;
     $count = 1;
     $testProductXpath = $this->theme->getCartSummaryCheckoutProductLoopNameXpath($count);
     $this->webDriver->wait()->until(ExpectedCondition::elementExists($testProductXpath, WebDriver::BY_XPATH));
     while ($this->webDriver->elementExists($testProductXpath, WebDriver::BY_XPATH)) {
         $xpath = $this->theme->getCartSummaryCheckoutProductLoopNameXpath($count);
         $nameElement = $this->webDriver->byXpath($xpath);
         $name = trim($nameElement->getText());
         $xpath = $this->theme->getCartSummaryCheckoutProductLoopPriceXpath($count);
         if ($this->webDriver->elementExists($xpath, WebDriver::BY_XPATH)) {
             $priceElement = $this->webDriver->byXpath($xpath);
             $price = trim($priceElement->getText());
             // We do not extract the number value so currency checks can be done
         } else {
             $price = 0;
         }
         $xpath = $this->theme->getCartSummaryCheckoutProductLoopQtyXpath($count);
         if ($this->webDriver->elementExists($xpath, WebDriver::BY_XPATH)) {
             $qtyElement = $this->webDriver->byXpath($xpath);
             $qty = trim($qtyElement->getText());
         } else {
             $qty = 0;
         }
         $xpath = $this->theme->getCartSummaryCheckoutProductLoopSubtotalXpath($count);
         if ($this->webDriver->elementExists($xpath, WebDriver::BY_XPATH)) {
             $subtotalElement = $this->webDriver->byXpath($xpath);
             $subtotal = trim($subtotalElement->getText());
         } else {
             $subtotal = 0;
         }
         $product = new Product($name, $qty, $price, $subtotal);
         $productIterator->addProduct($product);
         $testProductXpath = $this->theme->getCartSummaryCheckoutProductLoopNameXpath(++$count);
     }
     // Tax and shipping may not be displayed
     if ($this->webDriver->elementDisplayed($this->theme->getCartSummaryCheckoutTax(), WebDriver::BY_XPATH)) {
         $this->values[self::VALUE_TAX] = trim($this->webDriver->byXpath($this->theme->getCartSummaryCheckoutTax())->getText());
     }
     if ($this->webDriver->elementDisplayed($this->theme->getCartSummaryCheckoutShippingTotal(), WebDriver::BY_XPATH)) {
         $this->values[self::VALUE_SnH] = trim($this->webDriver->byXpath($this->theme->getCartSummaryCheckoutShippingTotal())->getText());
     }
     $this->values[self::VALUE_GRAND_TOTAL] = trim($this->webDriver->byXpath($this->theme->getCartSummaryCheckoutGrandTotal())->getText());
     $this->values[self::VALUE_SUBTOTAL] = trim($this->webDriver->byXpath($this->theme->getCartSummaryCheckoutSubTotal())->getText());
 }
Ejemplo n.º 27
0
 public function register($registerForNewsletter = false)
 {
     $this->navigator->navigateTo();
     $firstnameElement = $this->webdriver->byXpath($this->theme->getRegisterFirstNameXpath());
     $lastnameElement = $this->webdriver->byXpath($this->theme->getRegisterLastNameXpath());
     $emailElement = $this->webdriver->byXpath($this->theme->getRegisterEmailXpath());
     $passwordElement = $this->webdriver->byXpath($this->theme->getRegisterPasswordXpath());
     $confirmElement = $this->webdriver->byXpath($this->theme->getRegisterConfirmPasswordXpath());
     $submitElement = $this->webdriver->byXpath($this->theme->getRegisterSubmitXpath());
     $firstnameElement->sendKeys($this->customerIdentity->getBillingFirstName());
     $lastnameElement->sendKeys($this->customerIdentity->getBillingLastName());
     $emailElement->sendKeys($this->customerIdentity->getEmailAddress());
     $passwordElement->sendKeys($this->customerIdentity->getPassword());
     $confirmElement->sendKeys($this->customerIdentity->getPassword());
     $submitElement->click();
     $this->webdriver->wait()->until(ExpectedCondition::titleIs($this->theme->getMyAccountTitle()));
 }
Ejemplo n.º 28
0
 public function navigateTo($tab)
 {
     $tabs = explode('::', $tab);
     $tab = $header = array_shift($tabs);
     if (count($tabs)) {
         $header = array_shift($tabs);
     }
     $element = $this->webDriver->byXpath($this->themeConfiguration->getWidgetTabXpath($tab));
     $element->click();
     if ($header) {
         $this->webDriver->wait()->until(ExpectedCondition::elementExists($this->themeConfiguration->getWidgetTabHeaderXpath($header), WebDriver::BY_XPATH));
         $element = $this->webDriver->byXpath($this->themeConfiguration->getWidgetTabHeaderXpath($header));
     } else {
         $this->loadingMask->wait();
     }
     $this->webDriver->wait()->until(ExpectedCondition::visibilityOf($element));
 }
Ejemplo n.º 29
0
 public function testTwitterAuth()
 {
     // This part of the test will not work on your system.  You will need to change it.
     $this->commandOpen('http://magiumlib.loc/');
     $this->byText('Log In')->click();
     // This part of the test should work on your system.  If it doesn't work then something is probably wrong.
     // Make sure you configure your twitter account in the file /configuration/Magium/Twitter/Identities/Twitter.php
     /*
      * $this->username = '******';
      * $this->password = '******';
      */
     $action = $this->getAction(Login::ACTION);
     /* @var $action Login */
     $action->setIdentity($this->getIdentity(Twitter::IDENTITY));
     $action->execute();
     $this->webdriver->wait(5)->until(ExpectedCondition::elementExists('login-link'));
 }
Ejemplo n.º 30
0
 public function navigateTo($orderId, $doLoginIfNeeded = false)
 {
     if ($doLoginIfNeeded) {
         $this->adminLogin->login();
     }
     $this->adminMenuNavigator->navigateTo('Sales/Orders');
     $this->clearTableFilters->clear();
     $element = $this->webDriver->byId('sales_order_grid_filter_real_order_id');
     $element->sendKeys($orderId);
     $this->clickButton->click($this->themeConfiguration->getSearchButtonText());
     $this->testCase->sleep('100ms');
     $this->waitForLoadingMask->wait();
     $selectXpath = $this->themeConfiguration->getSelectOrderXpath($orderId);
     $this->testCase->assertElementDisplayed($selectXpath, WebDriver::BY_XPATH);
     $element = $this->webDriver->byXpath($selectXpath);
     $element->click();
     $this->webDriver->wait()->until(ExpectedCondition::titleContains($orderId));
 }