本文整理汇总了PHP中Behat\Mink\Element\NodeElement::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeElement::getAttribute方法的具体用法?PHP NodeElement::getAttribute怎么用?PHP NodeElement::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behat\Mink\Element\NodeElement
的用法示例。
在下文中一共展示了NodeElement::getAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restrictElements
/**
* @param array[] $allowedElements
* Element machine names.
*/
private function restrictElements(array $allowedElements)
{
// Match element tag with allowed.
if (!isset($allowedElements[$this->tag])) {
throw new \RuntimeException("Tag is not allowed: {$this->tag}.");
}
$types = $allowedElements[$this->tag];
// Restrict by types only if they are specified.
if (!empty($types)) {
$type = $this->element->getAttribute('type');
if (!in_array($type, $types)) {
throw new \RuntimeException(sprintf('Type "%s" is not allowed for "%s" tag', $type, $this->tag));
}
}
}
示例2: getEvaluation
/**
* Helper function how to read the evaluation from the evaluation element
* @param NodeElement $element
* @return string
*/
protected function getEvaluation($element)
{
$evaluation = $element->getAttribute('content');
$evaluation = floatval($evaluation);
$evaluation *= 2;
return (string) $evaluation;
}
示例3: createFromNode
public static function createFromNode(NodeElement $node)
{
$message = $node->find('css', '.noty_text')->getHtml();
//$x = $node->getOuterHtml();
$class = $node->getAttribute('class');
switch ($class) {
case 'noty_alert':
$type = 'alert';
break;
case 'noty_warning':
$type = 'warning';
break;
case 'noty_error':
$type = 'error';
break;
case 'noty_information':
$type = 'information';
break;
case 'noty_success':
$type = 'success';
break;
default:
$type = 'default';
}
return new NotyMessage($node, $type, $message);
}
示例4: 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);
}
示例5: fillTextField
/**
* Fills a text field element with $value, identified by its $label.
*
* @param NodeElement $label
* @param string $value
*/
protected function fillTextField(NodeElement $label, $value)
{
if (!$label->getAttribute('for') && null !== $label->channel) {
$label = $label->getParent()->find('css', sprintf('[data-scope="%s"] label', $label->channel));
}
$for = $label->getAttribute('for');
$field = $this->find('css', sprintf('#%s', $for));
$field->setValue($value);
}
示例6: testGetAttribute
public function testGetAttribute()
{
$expected = 'http://...';
$node = new NodeElement('input_tag', $this->session);
$this->driver->expects($this->once())->method('getAttribute')->with('input_tag', 'href')->will($this->returnValue($expected));
$this->assertEquals($expected, $node->getAttribute('href'));
}
示例7: waitForModalToAppear
/**
* @param NodeElement $modalContainer
* @param string $appearClass
*
* @todo it really shouldn't be here :)
*/
protected function waitForModalToAppear(NodeElement $modalContainer, $appearClass = 'in')
{
$this->getDocument()->waitFor(1, function () use($modalContainer, $appearClass) {
return false !== strpos($modalContainer->getAttribute('class'), $appearClass);
});
}
示例8: getStars
/**
* @param NodeElement $element
* @return string
*/
protected function getStars(NodeElement $element)
{
return $element->getAttribute('class');
}
示例9: getColumnFieldName
/**
* @param NodeElement $column
*
* @return string
*/
private function getColumnFieldName(NodeElement $column)
{
return preg_replace('/.*sylius-table-column-([^ ]+).*$/', '\\1', $column->getAttribute('class'));
}
示例10: get_field_node_type
/**
* Find the special type of a mahara field
*
* We look for the class to detect the correct type
*
* @param NodeElement $fieldnode The current node.
* @param Session $session The behat browser session
* @return mixed A NodeElement if we continue looking for the element type and String or false when we are done.
*/
protected static function get_field_node_type(NodeElement $fieldnode, Session $session)
{
$specialfieldnodetypes = array('artefactchooser', 'authlist', 'autocomplete', 'calendar', 'color', 'emaillist', 'expiry', 'filebrowser', 'files', 'image', 'multitext', 'password', 'rolepermissions', 'tags', 'userlist', 'weight', 'wysiwyg');
if ($class = $fieldnode->getAttribute('class')) {
if (in_array($class, $specialfieldnodetypes)) {
return $class;
}
}
return false;
}
示例11: get_field_node_type
/**
* Recursive method to find the field type.
*
* Depending on the field the felement class node is in a level or in another. We
* look recursively for a parent node with a 'felement' class to find the field type.
*
* @param NodeElement $fieldnode The current node.
* @param Session $session The behat browser session
* @return mixed A NodeElement if we continue looking for the element type and String or false when we are done.
*/
protected static function get_field_node_type(NodeElement $fieldnode, Session $session)
{
// Special handling for availability field which requires custom JavaScript.
if ($fieldnode->getAttribute('name') === 'availabilityconditionsjson') {
return 'availability';
}
// We look for a parent node with 'felement' class.
if ($class = $fieldnode->getParent()->getAttribute('class')) {
if (strstr($class, 'felement') != false) {
// Remove 'felement f' from class value.
return substr($class, 10);
}
// Stop propagation through the DOM, if it does not have a felement is not part of a moodle form.
if (strstr($class, 'fcontainer') != false) {
return false;
}
}
return self::get_field_node_type($fieldnode->getParent(), $session);
}
示例12: waitForTabToActivate
/**
* @param NodeElement $tabContainer
*/
protected function waitForTabToActivate($tabContainer)
{
$this->waitFor(function () use($tabContainer) {
return false !== strpos($tabContainer->getAttribute('class'), 'active');
});
}
示例13: filterLink
/**
* @param NodeElement $link
*
* @return bool|string
*/
private function filterLink(NodeElement $link)
{
$href = trim($link->getAttribute('href'));
if (empty($href) || $href === '/' || 0 === strpos($href, '#') || 0 === strpos($href, 'javascript:') || 0 === strpos($href, 'mailto:') || !preg_match('/^((https?|ftp)\\:\\/\\/)(www\\.)?.*/', $href, $matches)) {
return false;
}
// дополнить относительный урл базовым (из behat.yml)
$part = substr($href, 0, 1);
if ('/' == $part) {
// с учётом страницы, на которой находимся
$href = $this->getBehatParameter('base_url') . $href;
} elseif ('?' == $part) {
// с учётом страницы, на которой находимся
$href = $this->getBehatParameter('base_url') . $this->_pageMapped . $href;
}
return $href;
}
示例14: waitForModalToDisappear
/**
* @param NodeElement $modalContainer
*
* @throws \Exception
*/
protected function waitForModalToDisappear($modalContainer)
{
$i = 0;
while (false !== strpos($modalContainer->getAttribute('class'), 'in')) {
if (10 === $i) {
throw new \Exception('The confirmation modal was not closed...');
}
$this->getSession()->wait(100);
++$i;
}
}
示例15: fillTextField
/**
* Fills a text field element with $value, identified by its $label.
*
* @param \Behat\Mink\Element\NodeElement $label
* @param string $value
*/
protected function fillTextField($label, $value)
{
$for = $label->getAttribute('for');
$field = $this->find('css', sprintf('#%s', $for));
$field->setValue($value);
}