本文整理匯總了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;
}
}
}