forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTreeElement.php
108 lines (95 loc) · 2.33 KB
/
TreeElement.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Mtf\Client\Element;
use Magento\Mtf\Client\ElementInterface;
use Magento\Mtf\Client\Locator;
/**
* Typified element class for Tree elements.
*/
class TreeElement extends Tree
{
/**
* All selected checkboxes.
*
* @var string
*/
protected $selectedCheckboxes = '//input[@checked=""]';
/**
* Selector for plus image.
*
* @var string
*/
protected $imagePlus = './div/img[contains(@class, "-plus")]';
/**
* Selector for input.
*
* @var string
*/
protected $input = '/div/a/span';
/**
* Selector for parent element.
*
* @var string
*/
protected $parentElement = './../../../../../div/a/span';
/**
* Selected checkboxes.
*
* @var string
*/
protected $selectedLabels = '//input[@checked=""]/../a/span';
/**
* Pattern for child element node.
*
* @var string
*/
protected $pattern = '//li[@class="x-tree-node" and div/a/span[contains(text(),"%s")]]';
/**
* Regular pattern mask for node label.
*
* @var string
*/
protected $regPatternLabel = '`(.+) \(.*`';
/**
* Clear data for element.
*
* @return void
*/
public function clear()
{
$checkboxes = $this->getElements($this->selectedCheckboxes, Locator::SELECTOR_XPATH, 'checkbox');
foreach ($checkboxes as $checkbox) {
$checkbox->setValue('No');
}
}
/**
* Display children.
*
* @param string $element
* @return void
*/
protected function displayChildren($element)
{
$element = $this->find(sprintf($this->pattern, $element), Locator::SELECTOR_XPATH);
$plusButton = $element->find($this->imagePlus, Locator::SELECTOR_XPATH);
if ($plusButton->isVisible()) {
$plusButton->click();
$this->waitLoadChildren($element);
}
}
/**
* Get element label.
*
* @param ElementInterface $element
* @return string
*/
protected function getElementLabel(ElementInterface $element)
{
$value = $element->getText();
preg_match($this->regPatternLabel, $value, $matches);
return trim($matches[1]);
}
}