Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit 122e43b

Browse files
author
miguel
committed
[Behat] Remove xPath Helper
1 parent 9aabc6a commit 122e43b

File tree

1 file changed

+12
-38
lines changed

1 file changed

+12
-38
lines changed

Features/Context/SubContext/BrowserContext.php

+12-38
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,11 @@
99
*/
1010
namespace EzSystems\PlatformUIBundle\Features\Context\SubContext;
1111

12-
use EzSystems\BehatBundle\Helper\EzAssertion;
1312
use EzSystems\PlatformUIBundle\Features\Context\PlatformUI;
1413
use EzSystems\PlatformBehatBundle\Helper\Xpath;
1514

1615
class BrowserContext extends PlatformUI
1716
{
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-
4217
/**
4318
* @Given I clicked on/at (the) :link link
4419
* @When I click on/at (the) :link link
@@ -143,18 +118,17 @@ public function seeInputField($label)
143118
*/
144119
public function checkOption($option)
145120
{
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();
159133
}
160134
}

0 commit comments

Comments
 (0)