本文整理汇总了PHP中Behat\Mink\Session::getSelectorsHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getSelectorsHandler方法的具体用法?PHP Session::getSelectorsHandler怎么用?PHP Session::getSelectorsHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behat\Mink\Session
的用法示例。
在下文中一共展示了Session::getSelectorsHandler方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Initialize element.
*
* @param Session $session
*/
public function __construct(Session $session)
{
$this->xpathManipulator = new Manipulator();
$this->session = $session;
$this->driver = $session->getDriver();
$this->selectorsHandler = $session->getSelectorsHandler();
}
示例2: createElement
/**
* @param string $name
*
* @return NodeElement
*/
protected function createElement($name)
{
if (isset($this->elements[$name])) {
return new NodeElement($this->getSelectorAsXpath($this->elements[$name], $this->session->getSelectorsHandler()), $this->session);
}
throw new \InvalidArgumentException();
}
示例3: attachSeleniumSelector
/**
* Attaches Selenium selector, that is later used during annotation processing.
*
* @param Session $session Mink session.
*
* @return self
*/
protected function attachSeleniumSelector(Session $session)
{
$selectors_handler = $session->getSelectorsHandler();
if (!$selectors_handler->isSelectorRegistered('se')) {
$selectors_handler->registerSelector('se', new SeleniumSelector($selectors_handler));
}
return $session;
}
示例4: createElement
/**
* @param string $name
* @param array $parameters
*
* @return NodeElement
*/
private function createElement($name, array $parameters = [])
{
$definedElements = $this->getDefinedElements();
if (!isset($definedElements[$name])) {
throw new \InvalidArgumentException(sprintf('Could not find a defined element with name "%s". The defined ones are: %s.', $name, implode(', ', array_keys($definedElements))));
}
$elementSelector = strtr($definedElements[$name], $parameters);
return new NodeElement($this->getSelectorAsXpath($elementSelector, $this->session->getSelectorsHandler()), $this->session);
}
示例5: findField
/**
* @param $selector
* @return \Behat\Mink\Element\NodeElement
*/
protected function findField($selector)
{
$selector = $this->escape($selector);
$page = $this->session->getPage();
$field = $page->find('named', array('field', $this->session->getSelectorsHandler()->xpathLiteral($selector)));
if (!$field) {
$field = $page->find('css', $selector);
}
if (!$field) {
\PHPUnit_Framework_Assert::fail("Field matching id|name|label|value or css selector does not exists");
}
return $field;
}
示例6: findField
/**
* @param $selector
* @return \Behat\Mink\Element\NodeElement|null
* @throws \Codeception\Exception\ElementNotFound
*/
protected function findField($selector)
{
$page = $this->session->getPage();
$field = $page->find('named', array('field', $this->session->getSelectorsHandler()->xpathLiteral($selector)));
if (!$field and Locator::isCSS($selector)) {
$field = $page->find('css', $selector);
}
if (!$field and Locator::isXPath($selector)) {
$field = @$page->find('xpath', $selector);
}
if (!$field) {
throw new ElementNotFound($selector, "Field by name, label, CSS or XPath");
}
return $field;
}
示例7: findField
/**
* @param $selector
* @return \Behat\Mink\Element\NodeElement
*/
protected function findField($selector)
{
$page = $this->session->getPage();
$field = $page->find('named', array('field', $this->session->getSelectorsHandler()->xpathLiteral($selector)));
try {
if (!$field) {
$field = $page->find('css', $selector);
}
} catch (\Symfony\Component\CssSelector\Exception\ParseException $e) {
}
if (!$field) {
$field = @$page->find('xpath', $selector);
}
if (!$field) {
\PHPUnit_Framework_Assert::fail("Field matching id|name|label|value or css or xpath selector does not exist");
}
return $field;
}
示例8: testInstantiateWithoutOptionalDeps
public function testInstantiateWithoutOptionalDeps()
{
$session = new Session($this->driver);
$this->assertInstanceOf('Behat\\Mink\\Selector\\SelectorsHandler', $session->getSelectorsHandler());
}
示例9: seleniumSelectorToXpath
/**
* Returns 'xpath' selector, used to locate this WebElement.
*
* @param Session $session Session.
*
* @return string
*/
protected function seleniumSelectorToXpath(Session $session)
{
return $session->getSelectorsHandler()->selectorToXpath('se', $this->seleniumSelector);
}
示例10: testGetSelectorsHandler
public function testGetSelectorsHandler()
{
$this->assertSame($this->selectorsHandler, $this->session->getSelectorsHandler());
}
示例11: sprintf
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Behat\Mink\Driver\GoutteDriver;
use Behat\Mink\Session;
use Behat\Mink\Driver\Selenium2Driver;
//$driver = new GoutteDriver();
$driver = new Selenium2Driver();
$session = new Session($driver);
$session->start();
$session->visit('http://jurassicpark.wikia.com');
//echo "Status code: ". $session->getStatusCode() . "\n";
echo "Current URL: " . $session->getCurrentUrl() . "\n";
$page = $session->getPage();
echo "First 160 chars: " . substr($page->getText(), 0, 160) . "\n";
//$anchorEle = $page->find('css', 'h3 a.title');
//$spanEle = $anchorElement->find('css', 'span.emph');
$element = $page->find('css', '.subnav-2 li a');
echo "The link text is: " . $element->getText() . "\n";
$selectorsHandler = $session->getSelectorsHandler();
$element = $page->find('named', array('link', $selectorsHandler->xpathLiteral('Random page')));
$element = $page->findLink('Random page');
echo sprintf("The URL is '%s'\n", $element->getAttribute('href'));
$element->click();
$element->click();
echo "Page URL after click: " . $session->getCurrentUrl() . "\n";
//behat-ls/vendor/behat/mink/src/Behat/Mink/Selector/NamedSelector.php@$selectors
$session->stop();
示例12: _setSession
/**
* Sets session.
*
* @param Session $session Session.
*
* @return self
*/
private function _setSession(Session $session)
{
$selectors_handler = $session->getSelectorsHandler();
if (!$selectors_handler->isSelectorRegistered('se')) {
$selectors_handler->registerSelector('se', new SeleniumSelector());
}
$this->_session = $session;
return $this;
}