当前位置: 首页>>代码示例>>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;未经允许,请勿转载。