Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Fpt.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Block\Block;
10 use Magento\Mtf\Client\Locator;
11 
15 class Fpt extends Block
16 {
22  protected $price = './/*[@class="price"]';
23 
29  protected $fpt = './/*[@class="cart-tax-info"]/*[@class="weee"]/span';
30 
36  protected $fptTotal = './/*[@class="cart-tax-total"]/*[@class="weee"]/span';
37 
43  public function getFpt()
44  {
45  $cartProductFpt = $this->_rootElement->find($this->fpt, Locator::SELECTOR_XPATH);
46  if (!$cartProductFpt->isVisible()) {
47  $this->_rootElement->find($this->price, Locator::SELECTOR_XPATH)->click();
48  }
49  return str_replace(',', '', $this->escapeCurrency($cartProductFpt->getText()));
50  }
51 
57  public function getFptTotal()
58  {
59  $cartProductFptTotal = $this->_rootElement->find($this->fptTotal, Locator::SELECTOR_XPATH);
60  $cartProductFptTotalText = $cartProductFptTotal->isVisible() ? $cartProductFptTotal->getText() : '';
61  return str_replace(',', '', $this->escapeCurrency($cartProductFptTotalText));
62  }
63 
70  protected function escapeCurrency($price)
71  {
72  preg_match("/^\\D*\\s*([\\d,\\.]+)\\s*\\D*$/", $price, $matches);
73  return (isset($matches[1])) ? $matches[1] : null;
74  }
75 }