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


PHP Crawler::selectButton方法代碼示例

本文整理匯總了PHP中Symfony\Component\DomCrawler\Crawler::selectButton方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crawler::selectButton方法的具體用法?PHP Crawler::selectButton怎麽用?PHP Crawler::selectButton使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DomCrawler\Crawler的用法示例。


在下文中一共展示了Crawler::selectButton方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 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();
 }
開發者ID:GrossumUA,項目名稱:Symfony3-Base-Instance,代碼行數:7,代碼來源:AbstractLoginTest.php

示例2: click

 public function click($link, $context = null)
 {
     if ($context) {
         $this->crawler = $this->match($context);
     }
     if (is_array($link)) {
         $this->clickByLocator($link);
         return;
     }
     $anchor = $this->strictMatch(['link' => $link]);
     if (!count($anchor)) {
         $anchor = $this->crawler->selectLink($link);
     }
     if (count($anchor)) {
         $this->crawler = $this->client->click($anchor->first()->link());
         $this->forms = [];
         $this->debugResponse();
         return;
     }
     $buttonText = str_replace('"', "'", $link);
     $button = $this->crawler->selectButton($buttonText);
     if (count($button)) {
         $this->submitFormWithButton($button);
         $this->debugResponse();
         return;
     }
     $this->clickByLocator($link);
 }
開發者ID:hilmysyarif,項目名稱:erp,代碼行數:28,代碼來源:InnerBrowser.php

示例3: loginUsingFormUser

 /**
  * Use this function to connect to user in the application using login form
  * MORE SLOW, Use connectUser function above instead
  *
  * @param $username
  * @param $password
  * @return Client
  */
 protected function loginUsingFormUser($username, $password)
 {
     $this->client = static::createClient();
     $this->crawler = $this->client->request('GET', '/login');
     $credentials = array('_username' => $username, '_password' => $password);
     $form = $this->crawler->selectButton('_submit')->form($credentials);
     $this->client->submit($form);
     $this->client->followRedirects();
     return $this->client;
 }
開發者ID:TechGameCrew,項目名稱:GyverProject,代碼行數:18,代碼來源:BaseTestCase.php

示例4: click

 public function click($link, $context = null)
 {
     if ($context) {
         $this->crawler = $this->match($context);
     }
     if (is_array($link)) {
         $this->clickByLocator($link);
         return;
     }
     $anchor = $this->strictMatch(['link' => $link]);
     if (!count($anchor)) {
         $anchor = $this->getCrawler()->selectLink($link);
     }
     if (count($anchor)) {
         $this->crawler = $this->clientClick($anchor->first()->link());
         $this->forms = [];
         return;
     }
     $buttonText = str_replace('"', "'", $link);
     $button = $this->crawler->selectButton($buttonText);
     if (count($button)) {
         $buttonValue = [];
         if (strval($button->attr('name')) !== '' && $button->attr('value') !== null) {
             $buttonValue = [$button->attr('name') => $button->attr('value')];
         }
         $this->proceedSubmitForm($button->parents()->filter('form')->first(), $buttonValue);
         return;
     }
     try {
         $this->clickByLocator($link);
     } catch (MalformedLocatorException $e) {
         throw new ElementNotFound("name={$link}", "'{$link}' is invalid CSS and XPath selector and Link or Button");
     }
 }
開發者ID:vladislavl-hyuna,項目名稱:crmapp,代碼行數:34,代碼來源:InnerBrowser.php

示例5: click

 public function click($link, $context = null)
 {
     if ($context) {
         $this->crawler = $this->match($context);
     }
     if (is_array($link)) {
         $this->clickByLocator($link);
         return;
     }
     $anchor = $this->strictMatch(['link' => $link]);
     if (!count($anchor)) {
         $anchor = $this->crawler->selectLink($link);
     }
     if (count($anchor)) {
         $this->crawler = $this->client->click($anchor->first()->link());
         $this->forms = [];
         $this->debugResponse();
         return;
     }
     $buttonText = str_replace('"', "'", $link);
     $button = $this->crawler->selectButton($buttonText);
     if (count($button)) {
         $this->proceedSubmitForm($button->parents()->filter('form')->first(), [$button->attr('name') => $button->attr('value')]);
         return;
     }
     $this->clickByLocator($link);
 }
開發者ID:alexanderkuz,項目名稱:test-yii2,代碼行數:27,代碼來源:InnerBrowser.php

示例6: 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

示例7: clickCreateGameButton

 private function clickCreateGameButton(Crawler &$crawler, $gameName)
 {
     $form = $crawler->selectButton(self::CREATE_GAME_BUTTON_NAME)->form();
     $form['create_game_form[name]'] = $gameName;
     $crawler = $this->getClient()->submit($form);
     $this->assertStatusCode(StatusCode::MOVED_TEMPORARILY);
     $crawler = $this->getClient()->followRedirect();
     $this->assertStatusCode(StatusCode::OK);
 }
開發者ID:llvdl,項目名稱:DominoSymfony,代碼行數:9,代碼來源:GameOverviewControllerTest.php

示例8: assertShoppingListSave

 /**
  * @param Crawler $crawler
  * @param string  $label
  */
 protected function assertShoppingListSave(Crawler $crawler, $label)
 {
     $form = $crawler->selectButton('Save and Close')->form(['orob2b_shopping_list_type[label]' => $label]);
     $this->client->followRedirects(true);
     $crawler = $this->client->submit($form);
     $result = $this->client->getResponse();
     $this->assertHtmlResponseStatusCodeEquals($result, 200);
     $html = $crawler->html();
     $this->assertContains('Shopping List has been saved', $html);
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:14,代碼來源:ShoppingListControllerTest.php

示例9: clickPlayButton

 /**
  * @param Crawler $crawler
  * @param string $moveValue
  * @return Crawler
  */
 private function clickPlayButton(Crawler &$crawler, $turnNumber, $moveValue)
 {
     $button = $crawler->selectButton(self::PLAY_BUTTON_NAME);
     $this->assertEquals(1, count($button), 'play button is shown');
     $form = $button->form(['player_form[turnNumber]' => $turnNumber, 'player_form[move]' => $moveValue]);
     $crawler = $this->getClient()->submit($form);
     $this->assertStatusCode(StatusCode::MOVED_TEMPORARILY);
     $this->getClient()->followRedirect();
     $this->assertStatusCode(StatusCode::OK);
     return $crawler;
 }
開發者ID:llvdl,項目名稱:DominoSymfony,代碼行數:16,代碼來源:PlayerControllerTest.php

示例10: getForm

 /**
  * Get the form from the page with the given submit button text.
  *
  * @param  string|null  $buttonText
  * @return \Symfony\Component\DomCrawler\Form
  */
 protected function getForm($buttonText = null)
 {
     try {
         if ($buttonText) {
             return $this->crawler->selectButton($buttonText)->form();
         }
         return $this->crawler->filter('form')->form();
     } catch (InvalidArgumentException $e) {
         throw new InvalidArgumentException("Could not find a form that has submit button [{$buttonText}].");
     }
 }
開發者ID:hanifn,項目名稱:laravel-framework,代碼行數:17,代碼來源:InteractsWithPages.php

示例11: assertOrderSave

 /**
  * @param Crawler $crawler
  * @param User    $owner
  */
 protected function assertOrderSave(Crawler $crawler, User $owner)
 {
     $form = $crawler->selectButton('Save and Close')->form(['orob2b_order_type[owner]' => $owner->getId()]);
     $this->client->followRedirects(true);
     $crawler = $this->client->submit($form);
     $result = $this->client->getResponse();
     $this->assertHtmlResponseStatusCodeEquals($result, 200);
     $html = $crawler->html();
     $this->assertContains('Order has been saved', $html);
     $this->assertViewPage($crawler, $owner);
 }
開發者ID:hafeez3000,項目名稱:orocommerce,代碼行數:15,代碼來源:OrderControllerTest.php

示例12: assertSubtotals

 /**
  * @param Crawler $crawler
  * @param null|int $id
  */
 protected function assertSubtotals(Crawler $crawler, $id = null)
 {
     $form = $crawler->selectButton('Save and Close')->form();
     $form->getFormNode()->setAttribute('action', $this->getUrl('orob2b_order_subtotals', ['id' => $id]));
     $this->client->submit($form);
     $result = $this->client->getResponse();
     $this->assertJsonResponseStatusCodeEquals($result, 200);
     $data = json_decode($result->getContent(), true);
     $this->assertArrayHasKey('subtotals', $data);
     $this->assertArrayHasKey('subtotal', $data['subtotals']);
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:15,代碼來源:AjaxOrderControllerTest.php

示例13: 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

示例14: doResponsavelLogin

 /**
  *  Does login with ID and access key.
  **/
 public function doResponsavelLogin()
 {
     // get csrf token
     $this->crawler = $this->client->request('GET', $this->responsavel_endpoint);
     $token = $this->crawler->filter('input[name="csrfmiddlewaretoken"]');
     $token = $token->attr('value');
     // get form and submit
     $form = $this->crawler->selectButton('Acessar')->form();
     $this->crawler = $this->client->submit($form, ['matricula' => $this->username, 'chave' => $this->password, 'csrfmiddlewaretoken' => $token]);
     // set matricula
     $info = $this->crawler->filter('table[class="info"]');
     $this->matricula = trim($info->filter('td')->eq(5)->text());
 }
開發者ID:ivmelo,項目名稱:suapclient,代碼行數:16,代碼來源:SUAP.php

示例15: 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


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