protected function getSubmenuLinkNode(NodeElement $first_level_item, string $link_text)
    {
        $second_level_items = $first_level_item->findAll('css', 'ul li a');
        $submenu_link_node  = null;

        foreach ($second_level_items as $second_level_item) {
            $current_item_name = Util\stripTagsAndContent($second_level_item->getHtml());

            if (strtolower($link_text) !== strtolower($current_item_name)) {
                continue;
            }

            $id = $first_level_item->getAttribute('id');

            try {
                $element_exists = $this->getSession()->evaluateScript(
                    'return document.getElementById("' . $id . '");'
                );

                if ($element_exists !== null) {
                    // "Focus" (add hover class) on the toolbar link so the submenu appears.
                    $this->getSession()->executeScript(
                        'document.getElementById("' . $id . '").classList.add("hover");'
                    );
                }
            } catch (UnsupportedDriverActionException $e) {
                // This will fail for GoutteDriver but neither is it necessary.
            }

            $submenu_link_node = $second_level_item;
            break;
        }

        return $submenu_link_node;
    }
protected function getSubmenuLinkNode(NodeElement $first_level_item, string $link_text)
    {
        $second_level_items = $first_level_item->findAll('css', 'ul li a');
        $submenu_link_node  = null;

        foreach ($second_level_items as $second_level_item) {
            $current_item_name = Util\stripTagsAndContent($second_level_item->getHtml());

            if (strtolower($link_text) !== strtolower($current_item_name)) {
                continue;
            }

            $id = $first_level_item->getAttribute('id');

            try {
                $element_exists = $this->getSession()->evaluateScript(
                    'return document.getElementById("' . $id . '");'
                );

                if ($element_exists !== null) {
                    // "Focus" (add hover class) on the toolbar link so the submenu appears.
                    $this->getSession()->executeScript(
                        'document.getElementById("' . $id . '").classList.add("hover");'
                    );
                }
            } catch (UnsupportedDriverActionException $e) {
                // This will fail for GoutteDriver but neither is it necessary.
            }

            $submenu_link_node = $second_level_item;
            break;
        }

        return $submenu_link_node;
    }
protected function getSubmenuLinkNode ( NodeElement $ first_level_item , string $ link_text ) { $ second_level_items = $ first_level_item -> findAll ( 'css' , 'ul li a' ) ; $ submenu_link_node = null ; foreach ( $ second_level_items as $ second_level_item ) { $ current_item_name = Util \ stripTagsAndContent ( $ second_level_item -> getHtml ( ) ) ; if ( strtolower ( $ link_text ) !== strtolower ( $ current_item_name ) ) { continue ; } $ id = $ first_level_item -> getAttribute ( 'id' ) ; try { $ element_exists = $ this -> getSession ( ) -> evaluateScript ( 'return document.getElementById("' . $ id . '");' ) ; if ( $ element_exists !== null ) { // "Focus" (add hover class) on the toolbar link so the submenu appears. $ this -> getSession ( ) -> executeScript ( 'document.getElementById("' . $ id . '").classList.add("hover");' ) ; } } catch ( UnsupportedDriverActionException $ e ) { // This will fail for GoutteDriver but neither is it necessary. } $ submenu_link_node = $ second_level_item ; break ; } return $ submenu_link_node ; }
Returns a second-level toolbar NodeElement corresponding to the link text
under the given first-level toolbar NodeElement.

@param \Behat\Mink\Element\NodeElement $first_level_item The element to check under.
@param string                          $link_text        The link (text) to check for.

@return \Behat\Mink\Element\NodeElement|null
Returns a second - level toolbar NodeElement corresponding to the link text under the given first - level toolbar NodeElement .