Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ManageCouponCode.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Mtf\Client\Locator;
10 
15 {
16  const GENERATE_CODES_BUTTON_CSS_SELECTOR = ".action-default.scalable.generate";
17 
18  const LAST_GENERATED_COUPON_CODE_SELECTOR = "//*[@id=\"couponCodesGrid_table\"]/tbody/tr/td[2]";
19 
20  const SPINNER = ".loading-mask";
21 
27  public function generateCouponCodes()
28  {
29  $button = $this->_rootElement->find(self::GENERATE_CODES_BUTTON_CSS_SELECTOR);
30  $button->click();
31  }
32 
38  public function getGeneratedCouponCode()
39  {
40  $this->waitForSpinner();
41  $column = $this->_rootElement->find(self::LAST_GENERATED_COUPON_CODE_SELECTOR, Locator::SELECTOR_XPATH);
42  return $column->getText();
43  }
44 
45  private function waitForSpinner()
46  {
47  $this->waitForElementNotVisible(self::SPINNER);
48  sleep(1);
49  }
50 }