Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DropdownmultiselectElement.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Client\Locator;
10 
14 class DropdownmultiselectElement extends MultiselectElement
15 {
21  protected $toggle = 'div';
22 
28  protected $selectedValue = 'li._selected';
29 
35  protected $optionByValue = './/li//label[contains(normalize-space(.), %s)]';
36 
43  public function setValue($values)
44  {
45  $this->eventManager->dispatchEvent(['set_value'], [__METHOD__, $this->getAbsoluteSelector()]);
46  $this->find($this->toggle)->click();
47  $this->deselectAll();
48  $values = is_array($values) ? $values : [$values];
49  foreach ($values as $value) {
50  $this->find(
51  sprintf($this->optionByValue, $this->escapeQuotes($value)),
52  Locator::SELECTOR_XPATH
53  )->click();
54  }
55  $this->find($this->toggle)->click();
56  }
57 
63  public function getValue()
64  {
65  $this->eventManager->dispatchEvent(['get_value'], [__METHOD__, $this->getAbsoluteSelector()]);
66  $values = [];
67  $this->find($this->toggle)->click();
68  $options = $this->getElements($this->selectedValue);
69  foreach ($options as $option) {
70  $values[] = $option->getText();
71  }
72  $this->find($this->toggle)->click();
73 
74  return $values;
75  }
76 
82  public function deselectAll()
83  {
84  $options = $this->getElements($this->selectedValue);
86  foreach ($options as $option) {
87  $option->click();
88  }
89  }
90 }
taxRateField find('.mselect-list') .on( 'click.mselect-edit'
Definition: edit.phtml:162
$values
Definition: options.phtml:88
$value
Definition: gender.phtml:16