diff --git a/lib/Magento/Actions/Checkout/ShippingMethods/FirstAvailable.php b/lib/Magento/Actions/Checkout/ShippingMethods/FirstAvailable.php index d84155f..60ae828 100644 --- a/lib/Magento/Actions/Checkout/ShippingMethods/FirstAvailable.php +++ b/lib/Magento/Actions/Checkout/ShippingMethods/FirstAvailable.php @@ -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; @@ -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(); } } -} \ No newline at end of file +} diff --git a/tests/Magento/Checkout/ShippingTest.php b/tests/Magento/Checkout/ShippingTest.php index ca9375d..53953d1 100644 --- a/tests/Magento/Checkout/ShippingTest.php +++ b/tests/Magento/Checkout/ShippingTest.php @@ -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; @@ -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(); @@ -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()); @@ -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'); @@ -49,4 +52,4 @@ public function testShippingThrowsExceptionWhenElementNotFound() $this->getAction(GuestCheckout::ACTION)->execute(); } -} \ No newline at end of file +}