Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ToggleDropdown.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Client\Element\SimpleElement;
10 use Magento\Mtf\Client\Locator;
11 
16 class ToggleDropdown extends SimpleElement
17 {
23  protected $field = './/button/span';
24 
30  protected $listOptions = './/ul[@data-role="dropdown-menu"]';
31 
37  protected $optionByText = './/ul[@data-role="dropdown-menu"]/li/a[.="%s"]';
38 
45  public function setValue($value)
46  {
47  $this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
48 
49  if ($value != $this->getValue()) {
50  $value = ('Yes' == $value) ? '%' : '$';
51 
52  $this->find($this->field, Locator::SELECTOR_XPATH)->click();
53  $this->waitListOptionsVisible();
54  $this->find(sprintf($this->optionByText, $value), Locator::SELECTOR_XPATH)->click();
55  }
56  }
57 
63  public function getValue()
64  {
65  $this->eventManager->dispatchEvent(['get_value'], [__METHOD__, $this->getAbsoluteSelector()]);
66 
67  $value = $this->find($this->field, Locator::SELECTOR_XPATH)->getText();
68  return ('%' == $value) ? 'Yes' : 'No';
69  }
70 
76  protected function waitListOptionsVisible()
77  {
78  $browser = $this;
79  $selector = $this->listOptions;
80  $browser->waitUntil(
81  function () use ($browser, $selector) {
82  return $browser->find($selector, Locator::SELECTOR_XPATH)->isVisible() ? true : null;
83  }
84  );
85  }
86 }
taxRateField find('.mselect-list') .on( 'click.mselect-edit'
Definition: edit.phtml:162
$value
Definition: gender.phtml:16