本文整理汇总了PHP中Behat\Mink\Element\NodeElement::getXpath方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeElement::getXpath方法的具体用法?PHP NodeElement::getXpath怎么用?PHP NodeElement::getXpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behat\Mink\Element\NodeElement
的用法示例。
在下文中一共展示了NodeElement::getXpath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(NodeElement $node, Session $session)
{
if (!$node->hasClass(self::NOTICE_CLASS)) {
throw new \InvalidArgumentException(sprintf('Provided node does not have class %s', self::NOTICE_CLASS));
}
parent::__construct($node->getXpath(), $session);
}
示例2: fromNodeElement
/**
* Creates Element instance based on existing NodeElement instance.
*
* @param NodeElement $node_element Node element.
* @param IPageFactory $page_factory Page factory.
*
* @return static
* @throws ElementException When page factory is missing.
*/
public static function fromNodeElement(NodeElement $node_element, IPageFactory $page_factory = null)
{
if (!isset($page_factory)) {
throw new ElementException('Page factory is required to create this element', ElementException::TYPE_PAGE_FACTORY_REQUIRED);
}
$selenium_selector = array(How::XPATH => $node_element->getXpath());
return new static($selenium_selector, $page_factory);
}
示例3: setNode
/**
* @param NodeElement $node
*/
public function setNode(NodeElement $node)
{
$this->node = $node;
$this->setXpath($node->getXpath());
$this->visible = $node->isVisible();
$id = $node->getAttribute('id');
if ($id) {
$this->setId($id);
}
$classes = $node->getAttribute('class');
if ($classes) {
$this->classes = explode(' ', $classes);
}
$this->attributes = self::parseAttribs($node);
}
示例4: testGetXpath
public function testGetXpath()
{
$node = new NodeElement('some custom xpath', $this->session);
$this->assertEquals('some custom xpath', $node->getXpath());
$this->assertNotEquals('not some custom xpath', $node->getXpath());
}
示例5: fromNodeElement
/**
* Creates Element instance based on existing NodeElement instance.
*
* @param NodeElement $node_element Node element.
* @param IPageFactory $page_factory Page factory.
*
* @return static
*/
public static function fromNodeElement(NodeElement $node_element, IPageFactory $page_factory = null)
{
$selenium_selector = array(How::XPATH => $node_element->getXpath());
return new static($selenium_selector, $node_element->getSession());
}
示例6: dragElementTo
/**
* Drags an element on another one.
* Works better than the standard dragTo.
*
* @param NodeElement $element
* @param NodeElement $dropZone
*/
public function dragElementTo(NodeElement $element, NodeElement $dropZone)
{
$session = $this->getSession()->getDriver()->getWebDriverSession();
$from = $session->element('xpath', $element->getXpath());
$to = $session->element('xpath', $dropZone->getXpath());
$session->moveto(['element' => $from->getID()]);
$session->buttondown('');
$session->moveto(['element' => $to->getID()]);
$session->buttonup('');
}
示例7: __construct
/**
* A bit of a hack, we require the Session to create instances of WPTableRow, so we store it here
* @param NodeElement $node
* @param Session $session
*/
public function __construct(NodeElement $node, Session $session)
{
parent::__construct($node->getXpath(), $session);
$this->session = $session;
}
示例8: executeJsOnElement
/**
* @param NodeElement $element
* @param string $script
*
* @example
* $this->executeJsOnElement($this->element('*', 'Meta tags'), 'return jQuery({{ELEMENT}}).text();');
* $this->executeJsOnElement($this->element('*', '#menu'), '{{ELEMENT}}.focus();');
*
* @throws \Exception
*
* @return mixed
*/
public function executeJsOnElement(NodeElement $element, $script)
{
$session = $this->getWebDriverSession();
// We need to trigger something with "withSyn" method, because, otherwise an element won't be found.
$element->focus();
$this->processJavaScript($script)->debug([$script]);
return $session->execute(['script' => str_replace('{{ELEMENT}}', 'arguments[0]', $script), 'args' => [['ELEMENT' => $session->element('xpath', $element->getXpath())->getID()]]]);
}