本文整理汇总了PHP中Symfony\Component\BrowserKit\Client::click方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::click方法的具体用法?PHP Client::click怎么用?PHP Client::click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\BrowserKit\Client
的用法示例。
在下文中一共展示了Client::click方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clickByLocator
protected function clickByLocator($link)
{
$nodes = $this->match($link);
if (!$nodes->count()) {
throw new ElementNotFound($link, 'Link or Button by name or CSS or XPath');
}
foreach ($nodes as $node) {
$tag = $node->nodeName;
$type = $node->getAttribute('type');
if ($tag == 'a') {
$this->crawler = $this->client->click($nodes->first()->link());
$this->forms = [];
$this->debugResponse();
return;
} elseif(
($tag == 'input' && in_array($type, array('submit', 'image'))) ||
($tag == 'button' && $type == 'submit'))
{
$this->submitFormWithButton($nodes->first());
$this->debugResponse();
return;
}
}
}
示例2: click
public function click($link)
{
$link = $this->escape($link);
$anchor = $this->crawler->selectLink($link);
if (count($anchor)) {
$this->crawler = $this->client->click($anchor->first()->link());
$this->debugResponse();
return;
}
$button = $this->crawler->selectButton($link);
if (count($button)) {
$this->submitFormWithButton($button);
$this->debugResponse();
return;
}
\PHPUnit_Framework_Assert::fail("Link or button for '{$link}' was not found");
}
示例3: click
public function click($link, $context = null)
{
$literal = Crawler::xpathLiteral($link);
if ($context) {
$this->crawler = $this->match($context);
}
$anchor = $this->crawler->filterXPath('.//a[.=' . $literal . ']');
if (!count($anchor)) {
$anchor = $this->crawler->selectLink($link);
}
if (count($anchor)) {
$this->crawler = $this->client->click($anchor->first()->link());
$this->debugResponse();
return;
}
$button = $this->crawler->selectButton($link);
if (count($button)) {
$this->submitFormWithButton($button);
$this->debugResponse();
return;
}
$nodes = $this->match($link);
if (!$nodes->count()) {
throw new ElementNotFound($link, 'Link or Button by name or CSS or XPath');
}
foreach ($nodes as $node) {
$tag = $node->nodeName;
$type = $node->getAttribute('type');
if ($tag == 'a') {
$this->crawler = $this->client->click($nodes->first()->link());
$this->debugResponse();
return;
} elseif ($tag == 'input' && in_array($type, array('submit', 'image')) || $tag == 'button' && $type == 'submit') {
$this->submitFormWithButton($nodes->first());
$this->debugResponse();
return;
}
}
}
示例4: click
public function click($link, $context = null)
{
$literal = Crawler::xpathLiteral($link);
if ($context) {
$this->crawler = $this->match($context);
}
$anchor = $this->crawler->filterXPath('.//a[.=' . $literal . ']');
if (!count($anchor)) {
$anchor = $this->crawler->selectLink($link);
}
if (count($anchor)) {
$this->crawler = $this->client->click($anchor->first()->link());
$this->debugResponse();
return;
}
$button = $this->crawler->selectButton($link);
if (count($button)) {
$this->submitFormWithButton($button);
$this->debugResponse();
return;
}
$nodes = $this->match($link);
if ($nodes->count()) {
foreach ($nodes as $node) {
if ($node->nodeName == 'a') {
$this->crawler = $this->client->click($nodes->first()->link());
$this->debugResponse();
return;
} elseif ($node->nodeName == 'input' && $node->getAttribute('type') == 'submit') {
$this->submitFormWithButton($nodes->first());
$this->debugResponse();
return;
}
}
}
\PHPUnit_Framework_Assert::fail("Link or button for '{$link}' was not found");
}
示例5: clickByLocator
protected function clickByLocator($link)
{
$nodes = $this->match($link);
if (!$nodes->count()) {
throw new ElementNotFound($link, 'Link or Button by name or CSS or XPath');
}
foreach ($nodes as $node) {
$tag = $node->nodeName;
$type = $node->getAttribute('type');
if ($tag === 'a') {
$this->crawler = $this->client->click($nodes->first()->link());
$this->forms = [];
$this->debugResponse();
break;
} elseif (in_array($tag, ['input', 'button']) && in_array($type, ['submit', 'image'])) {
$this->proceedSubmitForm($nodes->parents()->filter('form')->first(), [$nodes->first()->attr('name') => $nodes->first()->attr('value')]);
break;
}
}
}