简体   繁体   中英

Laravel 5.2.x test click link with a body having special characters

How can a link be tested if its body has special characters like "@"?

Example:

<a href="foo.php">foo@foo.com</a>
public function foo()
{
    $this->visit('/foo')
         ->click('foo@foo.com');
}

Error output:

Symfony\Component\CssSelector\Exception\SyntaxErrorException: Expected selector, but <delimiter "@" at 7> found.

I also tried to escape the "@" sign:

public function foo()
{
    $this->visit('/foo')
         ->click('foo\@foo.com');
}

Error output:

InvalidArgumentException: Could not find a link with a body, name, or ID attribute of [foo\@foo.com].

What version of Laravel 5 are you using, as this doesn't happen if Laravel 5.2.x.

However, you can try escaping the @ sign as follows:

public function foo()
{
    $this->visit('/foo')
         ->click('foo\@foo.com');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM