本文整理汇总了PHP中Behat\Mink\Session::getCurrentUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getCurrentUrl方法的具体用法?PHP Session::getCurrentUrl怎么用?PHP Session::getCurrentUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behat\Mink\Session
的用法示例。
在下文中一共展示了Session::getCurrentUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'], '/') . '/');
}
示例2: prepareSessionIfNeeded
private function prepareSessionIfNeeded()
{
if (!$this->minkSession->getDriver() instanceof Selenium2Driver) {
return;
}
if (false !== strpos($this->minkSession->getCurrentUrl(), $this->minkParameters['base_url'])) {
return;
}
$this->homePage->open();
}
示例3: getCurrentPageWithForm
/**
* {@inheritdoc}
*
* @throws \LogicException
*/
public function getCurrentPageWithForm(array $pages)
{
$routeParameters = $this->urlMatcher->match(parse_url($this->session->getCurrentUrl(), PHP_URL_PATH));
Assert::allIsInstanceOf($pages, SymfonyPageInterface::class);
foreach ($pages as $page) {
if ($routeParameters['_route'] === $page->getRouteName()) {
return $page;
}
}
throw new \LogicException('Route name could not be matched to provided pages.');
}
示例4: getCurrentPageWithForm
/**
* {@inheritdoc}
*
* @throws \LogicException
*/
public function getCurrentPageWithForm(CreatePageInterface $createPage, UpdatePageInterface $updatePage)
{
$routeParameters = $this->urlMatcher->match($this->session->getCurrentUrl());
if (false !== strpos($routeParameters['_route'], 'create')) {
return $createPage;
}
if (false !== strpos($routeParameters['_route'], 'update')) {
return $updatePage;
}
throw new \LogicException('Route name does not have any of "update" or "create" keyword, so matcher was unable to match proper page.');
}
示例5:
function it_throws_an_exception_if_neither_create_nor_update_key_word_has_been_found(Session $session, SymfonyPageInterface $createPage, SymfonyPageInterface $updatePage, UrlMatcherInterface $urlMatcher)
{
$session->getCurrentUrl()->willReturn('https://sylius.com/resource/show');
$urlMatcher->match('/resource/show')->willReturn(['_route' => 'sylius_resource_show']);
$createPage->getRouteName()->willReturn('sylius_resource_create');
$updatePage->getRouteName()->willReturn('sylius_resource_update');
$this->shouldThrow(\LogicException::class)->during('getCurrentPageWithForm', [[$createPage, $updatePage]]);
}
示例6:
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');
}
示例7: 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());
}
示例8: getResponseInfo
/**
* Returns response information string.
*
* @return string
*/
protected function getResponseInfo()
{
$driver = basename(str_replace('\\', '/', get_class($this->session->getDriver())));
$info = '+--[ ';
if (!in_array($driver, array('SahiDriver', 'SeleniumDriver'))) {
$info .= 'HTTP/1.1 ' . $this->session->getStatusCode() . ' | ';
}
$info .= $this->session->getCurrentUrl() . ' | ' . $driver . " ]\n|\n";
return $info;
}
示例9: 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));
}
示例10: grabFromCurrentUrl
public function grabFromCurrentUrl($uri = null)
{
if (!$uri) {
return $this->session->getCurrentUrl();
}
$matches = array();
$res = preg_match($uri, $this->session->getCurrentUrl(), $matches);
if (!$res) {
$this->fail("Couldn't match {$uri} in " . $this->session->getCurrentUrl());
}
if (!isset($matches[1])) {
$this->fail("Nothing to grab. A regex parameter required. Ex: '/user/(\\d+)'");
}
return $matches[1];
}
示例11: opened
/**
* Checks if the given page is currently opened in browser.
*
* @param Page $page Page to check.
*
* @return boolean
*/
public function opened(Page $page)
{
return $this->pageUrlMatcherRegistry->match($this->_session->getCurrentUrl(), $page);
}
示例12: testGetCurrentUrl
public function testGetCurrentUrl()
{
$this->driver->expects($this->once())->method('getCurrentUrl')->will($this->returnValue($ret = 'http://some.url'));
$this->assertEquals($ret, $this->session->getCurrentUrl());
}
示例13: sprintf
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Behat\Mink\Driver\GoutteDriver;
use Behat\Mink\Session;
use Behat\Mink\Driver\Selenium2Driver;
//$driver = new GoutteDriver();
$driver = new Selenium2Driver();
$session = new Session($driver);
$session->start();
$session->visit('http://jurassicpark.wikia.com');
//echo "Status code: ". $session->getStatusCode() . "\n";
echo "Current URL: " . $session->getCurrentUrl() . "\n";
$page = $session->getPage();
echo "First 160 chars: " . substr($page->getText(), 0, 160) . "\n";
//$anchorEle = $page->find('css', 'h3 a.title');
//$spanEle = $anchorElement->find('css', 'span.emph');
$element = $page->find('css', '.subnav-2 li a');
echo "The link text is: " . $element->getText() . "\n";
$selectorsHandler = $session->getSelectorsHandler();
$element = $page->find('named', array('link', $selectorsHandler->xpathLiteral('Random page')));
$element = $page->findLink('Random page');
echo sprintf("The URL is '%s'\n", $element->getAttribute('href'));
$element->click();
$element->click();
echo "Page URL after click: " . $session->getCurrentUrl() . "\n";
//behat-ls/vendor/behat/mink/src/Behat/Mink/Selector/NamedSelector.php@$selectors
$session->stop();
示例14: getFailureException
/**
* @param string $name
* @param Session $subject
* @param array $arguments
*
* @return FailureException
*/
protected function getFailureException($name, $subject, array $arguments)
{
return new FailureException(sprintf('Expected session to have status code %s, but it is %s.', $this->presenter->presentValue($subject->getCurrentUrl()), $this->presenter->presentValue($arguments[0])));
}
示例15: Session
<?php
require __DIR__ . '/vendor/autoload.php';
use Behat\Mink\Driver\GoutteDriver;
use Behat\Mink\Driver\Selenium2Driver;
use Behat\Mink\Session;
//$driver = new GoutteDriver();
$driver = new Selenium2Driver();
$session = new Session($driver);
$session->start();
$session->visit('http://jurassicpark.wikia.com');
//echo "The status code is ".$session->getStatusCode()."\n";
echo "The current URL is " . $session->getCurrentUrl() . "\n";
// Hallo! I'm a DocumentElement
$page = $session->getPage();
echo "The start of the page text is " . substr($page->getText(), 0, 56) . "\n";
// And I'm a NodeElement!
$nodeElement = $page->find('css', '.subnav-2 li a');
echo "The matched link text is " . $nodeElement->getText() . "\n";
$randomLink = $page->findLink('Random page');
echo "The matched URL is " . $randomLink->getAttribute('href') . "\n";
$randomLink->click();
echo "The new URL is " . $session->getCurrentUrl() . "\n";
$session->stop();