Skip to content

Commit

Permalink
Merge pull request #102 from kschroeder/master
Browse files Browse the repository at this point in the history
	Added a wait condition to make sure that the button for the shipping is clickable
  • Loading branch information
kschroeder authored Feb 21, 2017
2 parents b35a63f + f0250c5 commit 2d2dc71
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Magium\Magento\Actions\Checkout\ShippingMethods;

use Facebook\WebDriver\WebDriverBy;
use Magium\AbstractTestCase;
use Magium\Magento\AbstractMagentoTestCase;
use Magium\Magento\Themes\OnePageCheckout\AbstractThemeConfiguration;
Expand Down Expand Up @@ -40,8 +41,10 @@ public function choose($required)
}

if ($this->webDriver->elementDisplayed($this->theme->getDefaultShippingXpath(), AbstractTestCase::BY_XPATH)) {
$this->webDriver->byXpath($this->theme->getDefaultShippingXpath())->click();
$xpath = $this->theme->getDefaultShippingXpath();
$this->webDriver->wait()->until(ExpectedCondition::elementToBeClickable(WebDriverBy::xpath($xpath)));
$this->webDriver->byXpath($xpath)->click();
}
}

}
}
11 changes: 7 additions & 4 deletions tests/Magento/Checkout/ShippingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use Magium\Magento\AbstractMagentoTestCase;
use Magium\Magento\Actions\Cart\AddSimpleProductToCart;
use Magium\Magento\Actions\Checkout\GuestCheckout;
use Magium\Magento\Actions\Checkout\ShippingMethods\ByName;
use Magium\Magento\Actions\Checkout\ShippingMethods\NoSuchShippingMethodException;
use Magium\Magento\MissingInformationException;
use Magium\Magento\Navigators\Catalog\DefaultSimpleProduct;
use Magium\Magento\Navigators\Catalog\DefaultSimpleProductCategory;

Expand All @@ -15,7 +18,7 @@ public function testSelectShipping()
{
$this->setPaymentMethod('CashOnDelivery');
$this->setShippingMethod('ByName');
$this->assertInstanceOf('Magium\Magento\Actions\Checkout\ShippingMethods\ByName', $this->getShippingMethod());
$this->assertInstanceOf(ByName::class, $this->getShippingMethod());
$this->getShippingMethod()->setName('Fixed');
$this->commandOpen($this->getTheme()->getBaseUrl());
$this->getNavigator(DefaultSimpleProductCategory::NAVIGATOR)->navigateTo();
Expand All @@ -26,7 +29,7 @@ public function testSelectShipping()

public function testShippingThrowsExceptionWhenNameNotSpecified()
{
$this->setExpectedException('Magium\Magento\MissingInformationException');
$this->expectException(MissingInformationException::class);
$this->setPaymentMethod('CashOnDelivery');
$this->setShippingMethod('ByName');
$this->commandOpen($this->getTheme()->getBaseUrl());
Expand All @@ -38,7 +41,7 @@ public function testShippingThrowsExceptionWhenNameNotSpecified()

public function testShippingThrowsExceptionWhenElementNotFound()
{
$this->setExpectedException('Magium\Magento\Actions\Checkout\ShippingMethods\NoSuchShippingMethodException');
$this->expectException(NoSuchShippingMethodException::class);
$this->setPaymentMethod('CashOnDelivery');
$this->setShippingMethod('ByName');
$this->getShippingMethod()->setName('boogers');
Expand All @@ -49,4 +52,4 @@ public function testShippingThrowsExceptionWhenElementNotFound()
$this->getAction(GuestCheckout::ACTION)->execute();
}

}
}

0 comments on commit 2d2dc71

Please sign in to comment.