本文整理汇总了PHP中Behat\Mink\Session::getPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getPage方法的具体用法?PHP Session::getPage怎么用?PHP Session::getPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Behat\Mink\Session
的用法示例。
在下文中一共展示了Session::getPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* helper method for pages which needs an active login
*
* @throws ElementNotFoundException
*
* @return void
*/
protected function login()
{
$page = $this->session->getPage();
$page->fillField('email', 'root');
$page->fillField('password', 'developer');
$page->pressButton('Anmelden');
}
示例2: getMessageElement
/**
* @return NodeElement
*
* @throws ElementNotFoundException
*/
private function getMessageElement()
{
$messageElement = $this->session->getPage()->find('css', self::NOTIFICATION_ELEMENT_CSS);
if (null === $messageElement) {
throw new ElementNotFoundException($this->session->getDriver(), 'message element', 'css', self::NOTIFICATION_ELEMENT_CSS);
}
return $messageElement;
}
示例3: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
parent::setUp();
$this->page = $this->prophesize(DocumentElement::class);
$this->session = $this->prophesize(Session::class);
$this->session->getPage()->willReturn($this->page->reveal());
$this->webAssert = $this->prophesize(WebAssert::class);
}
示例4: openPage
public function openPage($url)
{
$session = new Session($this->getDriver());
$session->start();
$session->visit($url);
$this->page = $session->getPage();
}
示例5: dontSeeInTitle
public function dontSeeInTitle($title)
{
$el = $this->session->getPage()->find('css', 'title');
if (!$el) {
return $this->assertTrue(true);
}
$this->assertNotContains($title, $el->getText(), "page title contains {$title}");
}
示例6: dontSeeInField
/**
* Checks the value in field is not equal to value passed.
* Field is searched by its id|name|label|value or CSS selector.
*
* @param $field
* @param $value
*/
public function dontSeeInField($field, $value)
{
$node = $this->session->getPage()->findField($field);
if (!$node) {
return \PHPUnit_Framework_Assert::fail(", field not found");
}
\PHPUnit_Framework_Assert::assertNotEquals($this->escape($value), $node->getValue());
}
示例7: 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();
}
示例8: checkSelectContainsOption
/**
* Check if a select has an option.
*
* @param string $select
* @param string $option
*
* @return bool True if the option found in the select, else false
*/
protected function checkSelectContainsOption($select, $option)
{
$obj = $this->session->getPage()->findField($select);
if ($obj === null) {
throw new \Exception(sprintf('Select box "%s" not found', $select));
}
$optionText = $obj->getText();
$regex = '/' . preg_quote($option, '/') . '/ui';
return preg_match($regex, $optionText) > 0;
}
示例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: 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;
}
示例11: grabTextFrom
public function grabTextFrom($cssOrXPathOrRegex)
{
$el = null;
if (Locator::isCSS($cssOrXPathOrRegex)) {
$el = $this->session->getPage()->find('css', $cssOrXPathOrRegex);
if ($el) {
return $el->getText();
}
}
if (!$el and Locator::isXPath($cssOrXPathOrRegex)) {
$el = @$this->session->getPage()->find('xpath', $cssOrXPathOrRegex);
if ($el) {
return $el->getText();
}
}
if (@preg_match($cssOrXPathOrRegex, $this->session->getPage()->getContent(), $matches)) {
return $matches[1];
}
throw new ElementNotFound($cssOrXPathOrRegex, 'CSS or XPath or Regex');
}
示例12: grabTextFrom
public function grabTextFrom($cssOrXPathOrRegex)
{
$el = null;
try {
$el = $this->session->getPage()->find('css', $cssOrXPathOrRegex);
} catch (\Symfony\Component\CssSelector\Exception\ParseException $e) {
}
if ($el) {
return $el->getText();
}
if (!$el) {
$el = @$this->session->getPage()->find('xpath', $cssOrXPathOrRegex);
}
if ($el) {
return $el->getText();
}
if (@preg_match($cssOrXPathOrRegex, $this->session->getPage()->getContent(), $matches)) {
return $matches[1];
}
$this->fail("Element that matches '{$cssOrXPathOrRegex}' not found");
}
示例13: 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();
示例14: wasPostRequest
/**
* If this was a POST request - we send something to the #extra_msg container
*
* @return bool
*/
protected function wasPostRequest()
{
$extraMsg = $this->session->getPage()->find('css', '#extra_msg')->getText();
return !empty($extraMsg);
}
示例15: iShouldGet
/**
* @Then I should get :expectedString
*/
public function iShouldGet($expectedString)
{
$body = $this->session->getPage()->getContent();
PHPUnit_Framework_Assert::assertEquals($expectedString, unserialize($body));
}