Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
JquerytreeElement.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Client\ElementInterface;
10 use Magento\Mtf\Client\Locator;
11 
15 class JquerytreeElement extends Tree
16 {
22  protected $rootElement = '//div[contains(@class, "tree x-tree jstree")]';
23 
29  protected $level = '/ul/li[contains(@class, "jstree")]';
30 
36  protected $pattern = '/ul/li[contains(@class, "jstree") and a[text() = "%s"]]';
37 
43  protected $openNode = '//li[contains(@class, "jstree-open") and a[text() = "%s"]]';
44 
50  protected $closedNode = '//li[contains(@class, "jstree-closed") and a[text() = "%s"]]';
51 
57  protected $parentElement = './../../../a';
58 
64  protected $input = '/a/ins[@class="jstree-checkbox"]';
65 
71  protected $selectedLabels = '//li[contains(@class, "jstree-checked")]/a';
72 
78  protected $selectedLabelsByLevel = '/ul/li[contains(@class, "jstree-checked")]/a';
79 
86  protected function displayChildren($element)
87  {
88  $element = $this->find(sprintf($this->openNode, $element), Locator::SELECTOR_XPATH);
89  if ($element->isVisible()) {
90  return;
91  }
92  $plusButton = $this->find(sprintf($this->closedNode, $element) . $this->input, Locator::SELECTOR_XPATH);
93  if ($plusButton->isVisible()) {
94  $plusButton->click();
95  $this->waitLoadChildren($element);
96  }
97  }
98 
105  protected function getElementLabel(ElementInterface $element)
106  {
107  return trim($element->getText());
108  }
109 
116  public function getStructure($level = null)
117  {
118  $nodesSelector = $this->getNodesSelector($level);
119  $nodes = $this->getElements($nodesSelector, Locator::SELECTOR_XPATH);
120 
121  return $this->prepareValues($nodes);
122  }
123 
130  protected function getNodesSelector($level)
131  {
132  $selector = $this->rootElement;
133  if ($level !== null) {
134  for ($i = 1; $i < $level; $i++) {
135  $selector .= $this->level;
136  }
137  $selector .= $this->selectedLabelsByLevel;
138  } else {
139  $selector .= $this->selectedLabels;
140  }
141 
142  return $selector;
143  }
144 }
prepareValues(array $checkboxes)
Definition: Tree.php:127
waitLoadChildren(ElementInterface $element)
Definition: Tree.php:174
taxRateField find('.mselect-list') .on( 'click.mselect-edit'
Definition: edit.phtml:162
$i
Definition: gallery.phtml:31
$element
Definition: element.phtml:12