Spins around an element until it exists

@throws ExpectationException
@param string $element
@param string $selectortype
@return void
10736
protected function ensure_element_exists($element, $selectortype) {

        // Getting the behat selector & locator.
        list($selector, $locator) = $this->transform_selector($selectortype, $element);

        // Exception if it timesout and the element is still there.
        $msg = 'The "' . $element . '" element does not exist and should exist';
        $exception = new ExpectationException($msg, $this->getSession());

        // It will stop spinning once the find() method returns true.
        $this->spin(
            function($context, $args) {
                // We don't use behat_base::find as it is already spinning.
                if ($context->getSession()->getPage()->find($args['selector'], $args['locator'])) {
                    return true;
                }
                return false;
            },
            array('selector' => $selector, 'locator' => $locator),
            self::get_extended_timeout(),
            $exception,
            true
        );

    }
1102397
public function elementShouldBeVisible($selector)
    {
        $session = $this->getSession();
        $page = $session->getPage();
        $element = $page->find('css', $selector);

        if (!$element) {
            throw new ElementNotFoundException($session, 'Element "'.$selector.'"');
        }

        \PHPUnit_Framework_TestCase::assertTrue($element->isVisible());
    }
1009829
public void hover(final Object... expected) {
        dispatcher.beforeHover(this, expected);

        new Actions(Grid.driver()).moveToElement(getElement()).perform();

        try {
            for (Object expect : expected) {
                if (expect instanceof AbstractElement) {
                    AbstractElement a = (AbstractElement) expect;
                    WebDriverWaitUtils.waitUntilElementIsVisible(a.getLocator());
                } else if (expect instanceof String) {
                    String s = (String) expect;
                    WebDriverWaitUtils.waitUntilElementIsVisible(s);
                }
            }
        } finally {
            processScreenShot();

            dispatcher.afterHover(this, expected);
        }
    }
224268
function ( selector ) {
            var el = this.element(),
                node = $B( selector ).element( true );
    
            if ( el && el.parentNode ) el.parentNode.replaceChild( el, node );
        }
1222428
public function onEndElement($parser, $element)
    {
        $this->parserLevel--;
        if ($this->parserLevel > 0) {
            return;

        }
        if ($element != \strtoupper($this->getIndex()->getElement())) {
            throw new ReadDataIndexException(
                "Unexpected closing of element '$element'."
            );

        }
        $this->parserPosition = \xml_get_current_byte_index($parser);
    }
630230
public function create($element, $inputType = null, $position = null)
    {
        if (!(is_string($element) || $element instanceof FormElement)) {
            throw new Exception('$element must be string or FormElement instance.');
        }

        // Create new element from string declaration ("title").
        if (is_string($element)) {
            $element = (new FormElement($element));
        }

        // Create Form Input Element from string declaration ("textarea")
        if (is_string($inputType)) {
            $oldInput = $element->getInput();
            $newInput = InputFactory::make($element->id(), $inputType);

            $newInput->setRelation(
                $oldInput->getRelation()
            )->setTranslatable(
                $oldInput->getTranslatable()
            );

            $element->setInput(
                $newInput
            );
        }

        // Allow a callable input type.
        if (is_callable($inputType)) {
            call_user_func_array($inputType, [$element]);
        }

        if (is_numeric($position)) {
            return $this->insert($element, $position);
        }

        // Push element
        $this->push($element);

        if (null !== $position) {
            return $this->move($element->id(), $position);
        }

        return $this;
    }
1234197
function setElementTemplate($html, $element = null)
    {
        if (is_null($element)) {
            $this->_elementTemplate = $html;
        } else {
            $this->_templates[$element] = $html;
        }
    }
906130
public function type($sSelector, $sText)
    {
        try {
            $this->getElementLazy($sSelector)->setValue($sText);
        } catch (ElementException $e) {
            sleep(1);
            $this->getElementLazy($sSelector)->setValue($sText);
        }
    }
860865
protected void execute(WebElement element, SeleniumBrowser browser, TestContext context) {
        if (StringUtils.hasText(element.getTagName())) {
            context.setVariable(element.getTagName(), element);
        }
    }
479836
protected function addSequentialNode(DOMElement $element, $value): void
    {
        if (empty($element->nodeValue)) {
            $element->nodeValue = \htmlspecialchars($value);
            return;
        }

        $child = $this->element($element->nodeName);
        $child->nodeValue = \htmlspecialchars($value);
        $element->parentNode->appendChild($child);
    }
1032493
private function process(array $element, $parent = null)
    {
        $apiElement = $element['element'];

        if (isset($this->elementMap[$apiElement])) {
            $this->processElement(
                $element,
                $this->elementMap[$apiElement],
                $parent
            );
        }

        if ($element['element'] === 'category') {
            // todo extend the element map to check for classes, then merge processCategory into processElement
            $this->processCategory($element, $parent);
        }
    }
418258
public function removeElement(AbstractElement $element)
	{
		$id = $element->getId();

		if (!isset($this->elements[$id])) {
			throw new MissingElementException("Element \"$id\" is not indexed.");
		}

		unset($this->elements[$id]);

		$indexedAttrs = array_intersect_key($element->getAttributes(), $this->index);
		foreach ($indexedAttrs as $key => $oldValue) {
			unset($this->index[$key][$oldValue][$id]);
		}
	}
876666
protected function sequential(DOMElement $element, $storage): void
    {
        if (\is_array($storage)) {
            $this->addCollectionNode($element, $storage);
            return;
        }

        $this->addSequentialNode($element, $storage);
    }
1341693
public function seeElementInDOM($selector, $attributes = [])
    {
        $this->enableImplicitWait();
        $els = $this->match($this->getBaseElement(), $selector);
        $els = $this->filterByAttributes($els, $attributes);
        $this->disableImplicitWait();
        $this->assertNotEmpty($els);
    }
1216997
public static function add( $element, $location = [] ) {
		if ( ! isset( self::$_elements[ $element ] ) ) {
			self::$_elements[ $element ] = [];
		}

		if ( empty( $location ) ) {
			$default_location = self::get_default_location( $element );

			if ( $default_location ) {
				self::$_elements[ $element ][] = [ $default_location ];
			} else {
				throw new \Exception( 'Element ' . $element . ' does not have a default location. You must supply the $location parameter.' );
			}
		} else {
			self::$_elements[ $element ][] = [ $location ];
		}

		add_action( 'init', [ __CLASS__, 'register_elements' ] );
	}
50250
public function assertHtmlContentMatches($selectorString, $expected)
    {
        $this->assertEqual(trim($this->getHtmlContent($selectorString)), $expected);
    }
784331
static function assertElementFound( $search, $element, $pageSection = null, $type = 'element' )
    {
        $section = ( $pageSection === null ) ? "" : " in '$pageSection' page section";
        Assertion::assertNotEmpty( $element, "Couldn't find '$search' $type" . $section );
    }