|
9 | 9 | */
|
10 | 10 | namespace EzSystems\PlatformUIBundle\Features\Context\SubContext;
|
11 | 11 |
|
12 |
| -use EzSystems\BehatBundle\Helper\EzAssertion; |
13 | 12 | use EzSystems\PlatformUIBundle\Features\Context\PlatformUI;
|
14 | 13 | use EzSystems\PlatformBehatBundle\Helper\Xpath;
|
15 | 14 |
|
16 | 15 | class BrowserContext extends PlatformUI
|
17 | 16 | {
|
18 |
| - /** |
19 |
| - * @var \EzSystems\BehatBundle\Helper\Xpath |
20 |
| - */ |
21 |
| - private $xpath; |
22 |
| - |
23 |
| - /** |
24 |
| - * @BeforeScenario |
25 |
| - */ |
26 |
| - public function prepareHelpers() |
27 |
| - { |
28 |
| - // initialize Helpers |
29 |
| - $this->xpath = new Xpath($this->getSession()); |
30 |
| - } |
31 |
| - |
32 |
| - /** |
33 |
| - * Getter for Xpath. |
34 |
| - * |
35 |
| - * @return \EzSystems\BehatBundle\Helper\Xpath |
36 |
| - */ |
37 |
| - public function getXpath() |
38 |
| - { |
39 |
| - return $this->xpath; |
40 |
| - } |
41 |
| - |
42 | 17 | /**
|
43 | 18 | * @Given I clicked on/at (the) :link link
|
44 | 19 | * @When I click on/at (the) :link link
|
@@ -143,18 +118,17 @@ public function seeInputField($label)
|
143 | 118 | */
|
144 | 119 | public function checkOption($option)
|
145 | 120 | {
|
146 |
| - $fieldElements = $this->getXpath()->findFields($option); |
147 |
| - EzAssertion::assertElementFound($option, $fieldElements, null, 'checkbox'); |
148 |
| - |
149 |
| - // this is needed for the cases where are checkboxes and radio's |
150 |
| - // side by side, for main option the radio and the extra being the |
151 |
| - // checkboxes values |
152 |
| - if (strtolower($fieldElements[0]->getAttribute('type')) !== 'checkbox') { |
153 |
| - $value = $fieldElements[0]->getAttribute('value'); |
154 |
| - $fieldElements = $this->getXpath()->findXpath("//input[@type='checkbox' and @value='$value']"); |
155 |
| - EzAssertion::assertElementFound($value, $fieldElements, null, 'checkbox'); |
156 |
| - } |
157 |
| - |
158 |
| - $fieldElements[0]->check(); |
| 121 | + $session = $this->getSession(); |
| 122 | + $selectorsHandler = $session->getSelectorsHandler(); |
| 123 | + $literal = $selectorsHandler->xpathLiteral($option); |
| 124 | + |
| 125 | + // To be able to work on mink 1.6 (ezplatform) & mink 1.5 (5.4+ezpublish-community) w/o deprecation exceptions |
| 126 | + $selector = $selectorsHandler->isSelectorRegistered('named_partial') ? |
| 127 | + $selectorsHandler->getSelector('named_partial') : |
| 128 | + $selectorsHandler->getSelector('named'); |
| 129 | + $xpath = $selector->translateToXPath(array('field', $literal)); |
| 130 | + |
| 131 | + $fieldElement = $session->getPage()->find('xpath', $xpath); |
| 132 | + $fieldElement->check(); |
159 | 133 | }
|
160 | 134 | }
|
0 commit comments