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


PHP Session::visit方法代碼示例

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


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

示例1: _shoot_shot

 /**
  *
  * @param \Pachico\Voyeur\Shot $shot
  * @return string
  */
 protected function _shoot_shot(Shot $shot)
 {
     // Starting sesion if not started yet (in short, open browser)
     if (!$this->_session->isStarted()) {
         $this->_log_out('Starting camera session');
         $this->_session->start();
     }
     $this->_log_out('Loading ' . $shot->get_uri());
     $this->_log_out("Resizing window to " . $shot->get_width() . 'x' . $shot->get_height());
     $this->_session->resizeWindow($shot->get_width(), $shot->get_height());
     // Load page
     $this->_session->visit($shot->get_uri());
     $this->_log_out("Loading finished");
     // Should I wait for something?
     if (count($shot->get_wait_for()) > 0) {
         foreach ($shot->get_wait_for() as $waitings) {
             $wait_time = key($waitings);
             $condition = is_null(current($waitings)) ? null : current($waitings);
             $this->_log_out("Waiting " . $wait_time . ' microseconds');
             $condition and $this->_log_out("Or until " . $condition);
             $this->_session->wait($wait_time, $condition);
         }
     }
     // Any scripts to execute?
     if (count($shot->get_scripts()) > 0) {
         foreach ($shot->get_scripts() as $script) {
             $script = $this->_get_script_file_content($script);
             $this->_session->executeScript($script);
         }
     }
     // Finally take the screenshot and return it
     $this->_log_out("Taking screenshot");
     $picture = $this->_session->getScreenshot();
     return $picture;
 }
開發者ID:pachico,項目名稱:voyeur,代碼行數:40,代碼來源:Voyeur.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->driver = new GoutteDriver();
     $this->session = new Session($this->driver);
     $this->session->start();
     $this->session->visit($this->baseUrl);
 }
開發者ID:kratenko,項目名稱:oc-server3,代碼行數:8,代碼來源:AbstractFrontendTest.php

示例3: prepareMinkSessionIfNeeded

 private function prepareMinkSessionIfNeeded()
 {
     if ($this->minkSession->getDriver() instanceof KernelDriver) {
         return;
     }
     if (false !== strpos($this->minkSession->getCurrentUrl(), $this->minkParameters['base_url'])) {
         return;
     }
     $this->minkSession->visit(rtrim($this->minkParameters['base_url'], '/') . '/');
 }
開發者ID:Mozan,項目名稱:Sylius,代碼行數:10,代碼來源:CookieSetter.php

示例4: openPage

 public function openPage($url)
 {
     $session = new Session($this->getDriver());
     $session->start();
     $session->visit($url);
     $this->page = $session->getPage();
 }
開發者ID:manasovdan,項目名稱:eTextBookEditor,代碼行數:7,代碼來源:eTextBookDriver.php

示例5: visit

 /**
  * Visit specified URL.
  *
  * @param string $url Url of the page.
  *
  * @return void
  */
 public function visit($url)
 {
     if (!$this->isStarted()) {
         $this->start();
     }
     parent::visit($url);
 }
開發者ID:mablae,項目名稱:phpunit-mink,代碼行數:14,代碼來源:SessionProxy.php

示例6: startSession

 /**
  * Create session.
  *
  * @return void
  */
 protected function startSession()
 {
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     $this->session->visit($_SERVER['WEB_FIXTURE_URL'] . '/tests/aik099/QATools/HtmlElementsLive/Element/index.html');
 }
開發者ID:virtua-network,項目名稱:qa-tools,代碼行數:12,代碼來源:TypifiedElementTestCase.php

示例7:

 function it_loads_base_url_and_sets_a_cookie_if_not_using_kernel_driver_and_driver_is_currently_outside_base_url(Session $minkSession, DriverInterface $driver)
 {
     $minkSession->getDriver()->willReturn($driver);
     $minkSession->getCurrentUrl()->willReturn('http://sylius.org');
     $minkSession->visit('http://localhost:8080/')->shouldBeCalled();
     $minkSession->setCookie('abc', 'def')->shouldBeCalled();
     $this->setCookie('abc', 'def');
 }
開發者ID:ahmadrabie,項目名稱:Sylius,代碼行數:8,代碼來源:CookieSetterSpec.php

示例8: iAmOn

 /**
  * @Given /^I am on "([^"]*)"$/
  */
 public function iAmOn($arg1)
 {
     if (!$this->session) {
         $this->iOpenBrowser();
     }
     $url = $arg1;
     $this->session->visit($url);
     $this->page = $this->session->getPage();
 }
開發者ID:Niggu,項目名稱:cloudrexx,代碼行數:12,代碼來源:FeatureContext.php

示例9: testBaseUrl

 public function testBaseUrl()
 {
     $client = new Client(require __DIR__ . '/../app.php');
     $driver = new BrowserKitDriver($client, 'http://localhost/foo/');
     $session = new Session($driver);
     $session->visit('http://localhost/foo/index.html');
     $this->assertEquals(200, $session->getStatusCode());
     $this->assertEquals('http://localhost/foo/index.html', $session->getCurrentUrl());
 }
開發者ID:saberyounis,項目名稱:Sonata-Project,代碼行數:9,代碼來源:BaseUrlTest.php

示例10: tryRecordTabsOnId

 /**
  * Test record tabs for a particular ID.
  *
  * @param Session $session  Session
  * @param string  $id       ID to load
  * @param bool    $encodeId Should we URL encode the ID?
  *
  * @return void
  */
 protected function tryRecordTabsOnId(Session $session, $id, $encodeId = true)
 {
     $url = $this->getVuFindUrl('/Record/' . ($encodeId ? rawurlencode($id) : $id));
     $session->visit($url);
     $this->assertEquals(200, $session->getStatusCode());
     $page = $session->getPage();
     $staffViewTab = $page->findById('details');
     $this->assertTrue(is_object($staffViewTab));
     $this->assertEquals('Staff View', $staffViewTab->getText());
     $staffViewTab->click();
     $this->assertEquals($url . '#details', $session->getCurrentUrl());
     $staffViewTable = $page->find('css', '#details-tab table.citation');
     $this->assertTrue(is_object($staffViewTable));
     $this->assertEquals('LEADER', substr($staffViewTable->getText(), 0, 6));
 }
開發者ID:joemontibello,項目名稱:vufind,代碼行數:24,代碼來源:RecordTest.php

示例11: getSession

 /**
  * Creates Mink session using current session strategy and returns it.
  *
  * @return Session
  */
 public function getSession()
 {
     if ($this->_session) {
         return $this->_session;
     }
     $browser = $this->getBrowser();
     try {
         $this->_session = $this->getSessionStrategy()->session($browser);
         if ($this->getCollectCodeCoverageInformation()) {
             $this->_session->visit($browser->getBaseUrl());
         }
     } catch (DriverException $e) {
         $message = 'The Selenium Server is not active on host %s at port %s';
         $this->markTestSkipped(sprintf($message, $browser->getHost(), $browser->getPort()));
     }
     return $this->_session;
 }
開發者ID:mablae,項目名稱:phpunit-mink,代碼行數:22,代碼來源:BrowserTestCase.php

示例12: checkUserAccessToPages

 /**
  * @param $not
  * @param TableNode $paths
  *
  * @throws \Exception
  *
  * @Given /^user should(| not) have an access to the following pages:$/
  */
 public function checkUserAccessToPages($not, TableNode $paths)
 {
     $result = [];
     $code = $not ? 403 : 200;
     // Use "GoutteDriver" to have an ability to check answer code.
     $driver = new Mink\Driver\GoutteDriver();
     $session = new Mink\Session($driver);
     $session->start();
     foreach (array_keys($paths->getRowsHash()) as $path) {
         $path = trim($path, '/');
         $session->visit($this->locatePath($path));
         if ($session->getStatusCode() !== $code) {
             $result[] = $path;
         }
     }
     if (!empty($result)) {
         throw new \Exception(sprintf('The following paths: "%s" are %s accessible!', implode(', ', $result), $not ? '' : 'not'));
     }
 }
開發者ID:spheresh,項目名稱:behat-drupal-propeople-context,代碼行數:27,代碼來源:RedirectContext.php

示例13: login

 /**
  * @return $session 
  */
 public static function login($username, $password)
 {
     $driver = new GoutteDriver();
     $session = new Session($driver);
     $session->start();
     $session->visit('https://github.com/login');
     $page = $session->getPage();
     $form = $page->find('css', '.auth-form form');
     if (null === $form) {
         throw new \Exception('Couldn\'t locate the login form.');
     }
     $form->fillField('login_field', $username);
     $form->fillField('password', $password);
     $form->submit();
     // @todo need to check if successfully logged in here...
     $dumper = new Dumper();
     file_put_contents(__DIR__ . '/../settings.yml', $dumper->dump(['github' => ['username' => $username, 'password' => $password]], 2));
     return $session;
 }
開發者ID:sebastianwestberg,項目名稱:Gitcommander,代碼行數:22,代碼來源:Auth.php

示例14: visit

 /**
  * @param string $url
  * @return \Behat\Mink\Element\DocumentElement
  */
 protected function visit($url)
 {
     $this->session->visit($url);
     return $this->session->getPage();
 }
開發者ID:sebastianbergmann,項目名稱:phpunit-mink-trait,代碼行數:9,代碼來源:TestCaseTrait.php

示例15: testVisit

 public function testVisit()
 {
     $this->driver->expects($this->once())->method('visit')->with($url = 'some_url');
     $this->session->visit($url);
 }
開發者ID:saberyounis,項目名稱:Sonata-Project,代碼行數:5,代碼來源:SessionTest.php


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