/**
  * Extract relevant google search results and switch urls to build environment for testing purpose
  *
  * @param $site
  * @param $searchResults
  * @param $pagesToCheck
  * @param $systemDomain
  * @return array
  */
 public function getURLS($site, $searchResults, $pagesToCheck, $systemDomain)
 {
     /* ?q= : search query */
     /* &as_qdr=all : deactivate Google Instant */
     /* &num=100 : set to 100 search results */
     $this->open('http://google.de/search?q=' . $site . '&as_qdr=all&num=' . $searchResults);
     sleep(2);
     /* @var $facade Menta_Component_Selenium1Facade */
     $facade = Menta_ComponentManager::get('Menta_Component_Selenium1Facade');
     $baseurl = preg_replace('[site:]', 'www.', $site);
     $urls = array();
     for ($k = $pagesToCheck; $k > 0; $k--) {
         $i = 1;
         $elements = $this->getSession()->elements(\WebDriver\Container::XPATH, "//div[@id='search']//h3[@class='r']//a[contains(@href,'" . $baseurl . "')]");
         if ($elements) {
             foreach ($elements as $element) {
                 $url = preg_replace('/^(http|https):\\/\\/(' . $baseurl . ')/', $systemDomain, $element->getAttribute('href'));
                 $urls[] = array("url" => $url);
                 $i++;
             }
         } else {
             $this->getTest()->assertTrue(FALSE, "there are no searchresults present");
         }
         if ($k > 1) {
             $this->getTest()->click("//a[@id='pnnext']");
             sleep(1);
         }
     }
     return $urls;
 }
 /**
  * Put simple products into cart
  *
  * @test
  */
 public function putItemsIntoCartFromProductSingleView()
 {
     $cart = Menta_ComponentManager::get('MagentoComponents_Pages_Cart');
     /* @var $cart MagentoComponents_Pages_Cart */
     $cart->clearCart();
     /* @var $helper MagentoComponents_Helper */
     $helper = Menta_ComponentManager::get('MagentoComponents_Helper');
     /* @var $singleView MagentoComponents_Pages_ProductSingleView */
     $singleView = Menta_ComponentManager::get('MagentoComponents_Pages_ProductSingleView');
     $this->assertEquals(0, $helper->getCartItemsFromHeader(), 'Cart items from eggs is not 0');
     $singleView->putProductsIntoCart($this->getConfiguration()->getValue('testing.simple.product.id'));
     $this->assertEquals(1, $helper->getCartItemsFromHeader(), 'Cart items from eggs is not 1');
     $singleView->putProductsIntoCart(52);
     $this->assertEquals(2, $helper->getCartItemsFromHeader(), 'Cart items from eggs is not 2');
     // add same product a second
     $singleView->putProductsIntoCart(52);
     /* @var $categoryView MagentoComponents_Pages_CategoryView */
     $categoryView = Menta_ComponentManager::get('MagentoComponents_Pages_CategoryView');
     $categoryView->open(10);
     $this->assertEquals(3, $helper->getCartItemsFromHeader(), 'Cart items from eggs is not 3 (from category view)');
     $cart->open();
     $this->assertEquals(3, $helper->getCartItemsFromHeader(), 'Cart items from eggs is not 3 (from cart view)');
     $this->assertEquals(2, $this->getHelperCommon()->getElementCount($cart->getCartTablePath() . "/tbody/tr"), 'Expecting 2 rows in cart');
     // remove second row
     $this->getHelperCommon()->click($cart->getCartTablePath() . '/tbody/tr[2]/td/a[' . Menta_Util_Div::contains($cart->__('Remove item'), 'title') . ']');
     $this->assertEquals(1, $helper->getCartItemsFromHeader(), 'Cart items from eggs is not 1 (from cart view)');
 }
 /**
  * Logout
  */
 public function logout()
 {
     $helper = Menta_ComponentManager::get('MagentoComponents_Helper');
     /* @var $helper MagentoComponents_Helper */
     $this->getHelperCommon()->click($helper->getLogoutLinkPath());
     $this->getHelperWait()->waitForElementPresent("//h1[" . Menta_Util_Div::containsText($this->__('You are now logged out')) . "]");
     $this->getHelperAssert()->assertElementPresent("//h1[" . Menta_Util_Div::containsText($this->__('You are now logged out')) . "]");
 }
 /**
  * Check user name when logged in
  * 
  * @test
  */
 public function userNameWhenLoggedIn()
 {
     /* @var $customer MagentoComponents_Pages_CustomerAccount */
     $customer = Menta_ComponentManager::get('MagentoComponents_Pages_CustomerAccount');
     $customer->login();
     $customer->openDashboard();
     $this->getHelperAssert()->assertElementContainsText('//div[' . Menta_Util_Div::contains('welcome-msg') . ']', 'Test User');
     $customer->logout();
 }
Esempio n. 5
0
 public function testTitle()
 {
     $session = Menta_SessionManager::getSession();
     $session->open('http://www.google.com/ncr');
     $assertHelper = Menta_ComponentManager::get('Menta_Component_Helper_Assert');
     /* @var $assertHelper Menta_Component_Helper_Assert */
     $assertHelper->setTest($this)->assertTitle('Google');
     Menta_SessionManager::closeSession();
 }
 /**
  * Check order confirmation mail
  *
  * @test
  * @depends orderItem
  * @return void
  * @param int $lastOrderNumber
  */
 public function checkOrderConfirmationMail($lastOrderNumber)
 {
     if (empty($lastOrderNumber)) {
         $this->markTestSkipped('No orderId from previous test found!');
     }
     /* @var $imapMail GeneralComponents_ImapMail */
     $imapMail = Menta_ComponentManager::get('GeneralComponents_ImapMail');
     $this->assertNotEmpty($lastOrderNumber);
     $imapMail->getMailContent('Main Store: New Order # ' . $lastOrderNumber);
 }
 /**
  * Assert role present
  *
  * @param string $role
  * @return void
  */
 public function assertRolesPresent($role)
 {
     $this->getHelperCommon()->open($this->getRolesUrl());
     $this->searchRoleName($role);
     sleep(1);
     // TODO: that's not nice!
     $grid = Menta_ComponentManager::get('MagentoComponents_Pages_Admin_Grid');
     /* @var $grid MagentoComponents_Pages_Admin_Grid */
     $grid->assertGridContainsValueInColumn('roleGrid', $role, 'field_1');
 }
 /**
  * Check user name when logged in
  * @test
  */
 public function userNameWhenLoggedIn()
 {
     $admin = Menta_ComponentManager::get('MagentoComponents_Pages_Admin');
     /* @var $admin MagentoComponents_Pages_Admin */
     $admin->openAdmin();
     $adminUser = $admin->getAdminUser();
     $admin->logIntoAdmin($adminUser['username'], $adminUser['password']);
     $this->getHelperAssert()->assertElementContainsText('//div[' . Menta_Util_Div::contains('header') . ']', $adminUser['username']);
     $admin->logoutFromAdmin();
 }
 /**
  * Check shipping address in order
  *
  * @param int $lastOrderNumber
  * @return void
  * @test
  * @group webservice_api
  * @depends orderWithDifferentShippingAddress
  */
 public function checkAddresses($lastOrderNumber)
 {
     if (empty($lastOrderNumber)) {
         $this->markTestSkipped('No orderId from previous test found!');
     }
     // check via Webservice API
     $api = Menta_ComponentManager::get('MagentoComponents_WebServiceApi');
     /* @var $api MagentoComponents_WebServiceApi */
     $order = $api->getOrderInfo($lastOrderNumber);
     $this->assertEquals('ShippingFirstname', $order['shipping_address']['firstname']);
     $this->assertEquals('ShippingLastname', $order['shipping_address']['lastname']);
     $this->assertEquals('BillingFirstname', $order['billing_address']['firstname']);
     $this->assertEquals('BillingLastname', $order['billing_address']['lastname']);
 }
 /**
  * Check upsell products present on product view page
  *
  * @test
  * @return void
  */
 public function checkUpsellProductsPresent()
 {
     /* @var $cart MagentoComponents_Pages_Cart */
     $cart = Menta_ComponentManager::get('MagentoComponents_Pages_Cart');
     $cart->clearCart();
     /* @var $singleView MagentoComponents_Pages_ProductSingleView */
     $singleView = Menta_ComponentManager::get('MagentoComponents_Pages_ProductSingleView');
     $singleView->openProduct(126);
     $this->getHelperAssert()->assertTextPresent('The Only Children: Paisley T-Shirt');
     $this->getHelperAssert()->assertElementPresent('id=product-price-39-upsell');
     $this->getHelperAssert()->assertElementPresent('id=product-price-119-upsell');
     $this->getHelperAssert()->assertElementPresent('id=product-price-123-upsell');
     // put one of the upsells into the cart
     $singleView->putProductsIntoCart(39);
     // after reloading the page the product should be  gone from upsells
     $singleView->openProduct(126);
     $this->getHelperAssert()->assertElementPresent('id=product-price-119-upsell');
     $this->getHelperAssert()->assertElementPresent('id=product-price-123-upsell');
 }
 /**
  * Login during checkout
  *
  * @test
  * @return void
  */
 public function loginDuringCheckout()
 {
     /* @var $productSingleView MagentoComponents_Pages_ProductSingleView */
     $productSingleView = Menta_ComponentManager::get('MagentoComponents_Pages_ProductSingleView');
     $productSingleView->putProductsIntoCart(array($this->getConfiguration()->getValue('testing.simple.product.id')));
     /* @var $checkout MagentoComponents_Pages_OnePageCheckout */
     $checkout = Menta_ComponentManager::get('MagentoComponents_Pages_OnePageCheckout');
     $checkout->open();
     //insert wrong credentials
     $checkout->signInWithExistingAccount('*****@*****.**', 'test123');
     $this->getHelperWait()->waitForTextPresent('Invalid login or password.');
     // insert correct username
     $checkout->signInWithExistingAccount($this->getConfiguration()->getValue('testing.frontend.user'), $this->getConfiguration()->getValue('testing.frontend.password'));
     $checkout->assertUserLogged();
     // click to myaccount
     /* @var $customer MagentoComponents_Pages_CustomerAccount */
     $customer = Menta_ComponentManager::get('MagentoComponents_Pages_CustomerAccount');
     $customer->openDashboard();
     $this->getHelperWait()->waitForTextPresent($this->getConfiguration()->getValue('testing.frontend.user'));
 }
 /**
  * @test
  * @depends orderMixedProducts
  * @return void
  * @param int $lastOrderNumber
  */
 public function checkOrderInfo($lastOrderNumber)
 {
     if (empty($lastOrderNumber)) {
         $this->markTestSkipped('No order id from previous test found');
     }
     $api = Menta_ComponentManager::get('MagentoComponents_WebServiceApi');
     /* @var $api AoeComponents_Magento_WebServiceApi */
     $orderInfo = $api->getOrderInfo($lastOrderNumber);
     $this->assertEquals('simple', $orderInfo['items'][0]['product_type']);
     $this->assertEquals('1111', $orderInfo['items'][0]['sku']);
     $this->assertEquals('Ottoman', $orderInfo['items'][0]['name']);
     $this->assertEquals('configurable', $orderInfo['items'][1]['product_type']);
     $this->assertEquals('coal_sm', $orderInfo['items'][1]['sku']);
     $this->assertEquals('Coalesce: Functioning On Impatience T-Shirt', $orderInfo['items'][1]['name']);
     $this->assertEquals('simple', $orderInfo['items'][2]['product_type']);
     $this->assertEquals('coal_sm', $orderInfo['items'][2]['sku']);
     $this->assertEquals('Coalesce: Functioning On Impatience T-Shirt', $orderInfo['items'][2]['name']);
     $this->assertEquals($orderInfo['items'][1]['item_id'], $orderInfo['items'][2]['parent_item_id']);
     $this->assertEquals('new', $orderInfo['state']);
     $this->assertEquals('pending', $orderInfo['status']);
 }
 /**
  * Check newsletter box and unsubscribe from newsletter
  *
  * @test
  */
 public function testUnCheckNewsletterboxAndSave()
 {
     /* @var $mail MagentoComponents_ImapMail */
     $mail = Menta_ComponentManager::get('MagentoComponents_ImapMail');
     $mail->deleteAllMailsMatching('Newsletter unsubscription success');
     /* @var $customerAccount MagentoComponents_Pages_CustomerAccount */
     $customerAccount = Menta_ComponentManager::get('MagentoComponents_Pages_CustomerAccount');
     $customerAccount->login();
     $customerAccount->openDashboard();
     $this->getHelperAssert()->assertElementPresent($customerAccount->getNewsletterEditPathInDashoboard());
     $this->getHelperCommon()->click($customerAccount->getNewsletterEditPathInDashoboard());
     if (!$this->getHelperCommon()->isSelected("//input[@id='subscription']")) {
         $this->markTestSkipped('Subscribe to newsletter already unchecked!');
     }
     $this->getHelperAssert()->assertElementPresent("//input[@id='subscription']");
     $this->getHelperCommon()->click("//input[@id='subscription']");
     $this->getHelperCommon()->isSelected("//input[@id='subscription']");
     $this->getHelperCommon()->click('//form[@id="form-validate"]//button[@type="submit"]');
     /* @var $message MagentoComponents_Pages_Message */
     $message = Menta_ComponentManager::get('MagentoComponents_Pages_Message');
     $message->waitForSuccessMessagePresent('The subscription has been removed.');
     $mail->checkNewsletterSignOutMail(array('firstname' => 'Test', 'lastname' => 'User'));
 }
 /**
  * Reset password
  *
  * @param string $resetLink
  * @return void
  * @test
  * @depends checkMail
  */
 public function resetPassword($resetLink)
 {
     if (empty($resetLink)) {
         $this->markTestSkipped('No reset link from previous test found');
     }
     /* @var $customerAccount MagentoComponents_Pages_CustomerAccount */
     $customerAccount = Menta_ComponentManager::get('MagentoComponents_Pages_CustomerAccount');
     $customerAccount->logoutViaOpen();
     $this->getHelperCommon()->open($resetLink);
     $this->getHelperAssert()->assertTextNotPresent('Your password reset link has expired.');
     $this->getHelperAssert()->assertTitle('Reset a Password', 'Title is not correct. Link was: ' . $resetLink);
     $password = $this->getConfiguration()->getValue('testing.frontend.password');
     $this->getHelperCommon()->type('id=password', $password);
     $this->getHelperCommon()->type('id=confirmation', $password);
     $this->getHelperCommon()->click('//form[@id="form-validate"]//button[@type="submit"]');
     /* @var $message MagentoComponents_Pages_Message*/
     $message = Menta_ComponentManager::get('MagentoComponents_Pages_Message');
     $message->waitForSuccessMessagePresent('Your password has been updated.');
     $this->getHelperAssert()->assertTitle('Customer Login');
     $this->getHelperAssert()->assertTextPresent('Your password has been updated.');
     // try to login
     $customerAccount->login();
 }
 /**
  * @test
  * @group unstable
  * @dataProvider sizeAndColorDataProvider
  * @param int $productId
  * @param int $sizeAttrId
  * @param int $colorAttrId
  * @param array $singleProducts
  * @param array $colorArray
  */
 public function sizeAndColorTest($productId, $sizeAttrId, $colorAttrId, $singleProducts, $colorArray)
 {
     /* @var $productView MagentoComponents_Pages_ProductSingleView */
     $productView = Menta_ComponentManager::get('MagentoComponents_Pages_ProductSingleView');
     $productView->openProduct($productId);
     $this->getHelperWait()->waitForElementPresent("id=product_addtocart_form");
     $productView->assertAddtoCartButton('inStock');
     foreach ($singleProducts as $key => $product) {
         // Choose size
         $productView->selectDropDownOption($product['size'], $sizeAttrId);
         $productView->assertDropdownSelectedValue($product['size'], $sizeAttrId);
         $productView->assertDropdownExistOptionLabelWithPrice($product['size'], $product['sizeLabel'], 0, $sizeAttrId);
         $productView->assertSelectedLabel("Choose an Option...", 272);
         //Choose color
         $productView->selectDropDownOption($product['color'], $colorAttrId);
         $productView->assertDropdownSelectedValue($product['color'], $colorAttrId);
         $productView->assertRegularPrice($colorArray[$product['color']]['price']);
         $productView->assertStatus($colorArray[$product['color']]['status']);
         // Product price and stock status after choosing size
         $productView->assertRegularPrice($product['price']);
         $productView->assertStatus($product['status']);
         $productView->assertAddtoCartButton($product['status']);
     }
 }
 /**
  * @group adds_testdata
  * @return array
  */
 public function testRegistrationWithoutNewsletterSignUp()
 {
     /* @var $customerAccount MagentoComponents_Pages_CustomerAccount */
     $customerAccount = Menta_ComponentManager::get('MagentoComponents_Pages_CustomerAccount');
     $customerAccount->openSplitLoginOrRegister();
     $this->testId = md5(uniqid(rand(), TRUE));
     $userAccount = array('username' => $customerAccount->createNewMailAddress('register'), 'password' => 'testtest', 'firstname' => "Test_{$this->testId}", 'lastname' => "User_{$this->testId}");
     $this->getHelperAssert()->assertElementPresent($customerAccount->getSplitPageRegistrationButtonPath(), "Can't find register button");
     $this->getHelperCommon()->open('/customer/account/create/');
     $this->getHelperWait()->waitForTextPresent($customerAccount->__('Create an Account'));
     $this->getHelperAssert()->assertTextPresent($customerAccount->__('Confirm Password'));
     $formFields = array('firstname', 'lastname', 'email_address', 'password', 'confirmation');
     foreach ($formFields as $formField) {
         $this->getHelperAssert()->assertElementPresent("id={$formField}");
     }
     $this->getHelperCommon()->type("id=firstname", $userAccount['firstname']);
     $this->getHelperCommon()->type("id=lastname", $userAccount['lastname']);
     // triggering revalidation
     $this->getHelperCommon()->type("id=email_address", $userAccount['username']);
     //$this->getHelperCommon()->type("id=email_address_confirm", $userAccount['username']);
     $this->getHelperCommon()->type("id=password", $userAccount['password']);
     $this->getHelperCommon()->type("id=confirmation", $userAccount['password']);
     // submit the form
     $this->getHelperCommon()->click($customerAccount->getRegistrationSubmitButtonPath());
     // Check if everything is ok and we're in sign in page with thank you information
     $this->getHelperWait()->waitForTextPresent('Thank you for registering with Main Store');
     $customerAccount->assertIsOnDashboard();
     //$this->getHelperAssert()->assertTextPresent('My Dashboard', "Couldn't register user: "******"Email/username not present.");
     $this->getHelperAssert()->assertTextPresent('You have not set a default billing address.');
     $this->getHelperAssert()->assertTextPresent('You have not set a default shipping address.');
     return $userAccount;
 }
 /**
  * Get Magento Helper
  *
  * @return MagentoComponents_Helper
  */
 public function getHelper()
 {
     return Menta_ComponentManager::get('MagentoComponents_Helper');
 }
Esempio n. 18
0
 /**
  * Get selenium1 api
  *
  * @return Menta_Component_Selenium1Facade
  */
 public function getSelenium1Facade()
 {
     if (is_null($this->selenium1Facade)) {
         $this->selenium1Facade = Menta_ComponentManager::get('Menta_Component_Selenium1Facade');
         $this->selenium1Facade->setTest($this);
     }
     return $this->selenium1Facade;
 }
Esempio n. 19
0
 /**
  * @param string|\WebDriver\Element $element
  * @param string $color
  *
  * @author Manish Jain <*****@*****.**>
  * @throws Exception
  */
 public function paintElement($element, $color = '#0000ff')
 {
     $commonHelper = Menta_ComponentManager::get('Menta_Component_Helper_Common');
     /* @var $commonHelper Menta_Component_Helper_Common */
     $this->addProcessingInstruction(new Menta_Util_Screenshot_RectangleProcessor($commonHelper->getElement($element), null, null, null, $color));
 }
Esempio n. 20
0
 /**
  * @param string $title
  *
  * @return Menta_Util_Screenshot
  */
 public function getScreenShot($title = '')
 {
     // don't init a new session if there is none
     if (!Menta_SessionManager::activeSessionExists()) {
         return false;
     }
     $screenshotHelper = Menta_ComponentManager::get('Menta_Component_Helper_Screenshot');
     /* @var $screenshotHelper Menta_Component_Helper_Screenshot */
     $base64Image = $screenshotHelper->takeScreenshotToString();
     $time = time();
     // put data into the screenshot object
     $screenshot = new Menta_Util_Screenshot();
     $screenshot->setBase64Image($base64Image);
     $screenshot->setTime($time);
     if (!is_null($title)) {
         $screenshot->setTitle($title);
     }
     $screenshot->setLocation($this->getSession()->url());
     return $screenshot;
 }
 /**
  *
  * Cart, onepage checkout, dashboard, order history screenshots
  *
  * @test
  * @return void
  */
 public function checkout()
 {
     /* @var $productView MagentoComponents_Pages_ProductSingleView */
     $productView = Menta_ComponentManager::get('MagentoComponents_Pages_ProductSingleView');
     $productView->putProductsIntoCart(51);
     /* @var $cart MagentoComponents_Pages_Cart */
     $cart = Menta_ComponentManager::get('MagentoComponents_Pages_Cart');
     $cart->open();
     $this->takeScreenshot('Cart with 1 item - simple product');
     $productView->openProduct($this->getConfiguration()->getValue('testing.configurable.product.id'));
     $productView->selectDropDownOption(100, 525);
     // small
     $productView->clickAddToCart();
     $cart->open();
     $this->takeScreenshot('Cart with 2 item - simple, configurable product');
     // Login / Register
     /* @var $customerAccount MagentoComponents_Pages_CustomerAccount */
     $customerAccount = Menta_ComponentManager::get('MagentoComponents_Pages_CustomerAccount');
     $customerAccount->openSplitLoginOrRegister();
     $this->takeScreenshot('Login/Register', 'Split page showing the registration or login form');
     $customerAccount->login();
     // dashboard
     $customerAccount->openDashboard();
     $this->takeScreenshot('Customer dashboard', 'Dashboard of an existing user with some orders');
     // order history
     $customerAccount->openOrderHistory();
     $this->takeScreenshot('Order history');
     // checkout
     /* @var $checkout MagentoComponents_Pages_OnePageCheckout */
     $checkout = Menta_ComponentManager::get('MagentoComponents_Pages_OnePageCheckout');
     $checkout->open();
     $this->takeScreenshot('OnePage Checkout', 'Default Checkout');
 }
 /**
  * Check product price in product page
  *
  * @param $productId
  * @param $price
  */
 public function checkSingleViewPrice($productId, $price)
 {
     $singleView = Menta_ComponentManager::get('MagentoComponents_Pages_ProductSingleView');
     /* @var $singleView MagentoComponents_Pages_ProductSingleView */
     $singleView->openProduct($productId);
     $singleView->assertRegularPrice($price);
 }
Esempio n. 23
0
 /**
  * Get wait helper
  *
  * @return Menta_Component_Helper_Wait
  */
 protected function getHelperWait()
 {
     return Menta_ComponentManager::get('Menta_Component_Helper_Wait');
 }