Symfony\Component\DomCrawler\Crawler::selectButton PHP Method

selectButton() public method

Selects a button by name or alt value for images.
public selectButton ( string $value ) : Crawler
$value string The button text
return Crawler A new instance of Crawler with the filtered list of nodes
    public function selectButton($value)
    {
        $translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")';
        $xpath = sprintf('descendant-or-self::input[((contains(%s, "submit") or contains(%s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ', $translate, $translate, static::xpathLiteral(' ' . $value . ' ')) . sprintf('or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ', $translate, static::xpathLiteral(' ' . $value . ' '), static::xpathLiteral($value), static::xpathLiteral($value)) . sprintf('| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]', static::xpathLiteral(' ' . $value . ' '), static::xpathLiteral($value), static::xpathLiteral($value));
        return $this->filterRelativeXPath($xpath);
    }

Usage Example

 protected function setUp()
 {
     $this->client = static::createClient();
     $this->client->followRedirects(true);
     $this->crawler = $this->client->request('GET', self::LOGIN_URL);
     $this->loginForm = $this->crawler->selectButton(self::LOGIN_BUTTON)->form();
 }
All Usage Examples Of Symfony\Component\DomCrawler\Crawler::selectButton