Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SwitcherElement.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Client\Locator;
10 
15 class SwitcherElement extends SimpleElement
16 {
22  protected $parentContainer = 'parent::div[@data-role="switcher"]';
23 
29  private $labelText = './following-sibling::label';
30 
37  public function setValue($value)
38  {
39  if (($value != 'Yes') && ($value != 'No')) {
40  throw new \UnexpectedValueException(
41  sprintf('Switcher element accepts only "Yes" and "No" values.')
42  );
43  }
44  if ($value != $this->getValue()) {
45  $this->find($this->labelText, Locator::SELECTOR_XPATH)->click();
46  }
47  }
48 
55  public function getValue()
56  {
57  if ($this->find($this->parentContainer, 'xpath')->find('input:checked')->isVisible()) {
58  return 'Yes';
59  } elseif ($this->find($this->parentContainer, 'xpath')->find('input')->isVisible()) {
60  return 'No';
61  } else {
62  throw new \Exception(
63  sprintf('Element %s not found on page', $this->getLocator())
64  );
65  }
66  }
67 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
taxRateField find('.mselect-list') .on( 'click.mselect-edit'
Definition: edit.phtml:162
$value
Definition: gender.phtml:16