當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Client::click方法代碼示例

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

    }
開發者ID:Vrian7ipx,項目名稱:cascadadev,代碼行數:27,代碼來源:InnerBrowser.php

示例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");
 }
開發者ID:BatVane,項目名稱:Codeception,代碼行數:17,代碼來源:Framework.php

示例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;
         }
     }
 }
開發者ID:lenninsanchez,項目名稱:donadores,代碼行數:39,代碼來源:Framework.php

示例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");
 }
開發者ID:NaszvadiG,項目名稱:ImageCMS,代碼行數:37,代碼來源:Framework.php

示例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;
         }
     }
 }
開發者ID:alexanderkuz,項目名稱:test-yii2,代碼行數:20,代碼來源:InnerBrowser.php


注:本文中的Symfony\Component\BrowserKit\Client::click方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。