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


PHP Util\Locator類代碼示例

本文整理匯總了PHP中Codeception\Util\Locator的典型用法代碼示例。如果您正苦於以下問題:PHP Locator類的具體用法?PHP Locator怎麽用?PHP Locator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: testLocatingElementPosition

 public function testLocatingElementPosition()
 {
     $this->assertEquals('(descendant-or-self::p)[position()=1]', Locator::firstElement('p'));
     $this->assertEquals('(descendant-or-self::p)[position()=last()]', Locator::lastElement('p'));
     $this->assertEquals('(descendant-or-self::p)[position()=1]', Locator::elementAt('p', 1));
     $this->assertEquals('(descendant-or-self::p)[position()=last()-0]', Locator::elementAt('p', -1));
     $this->assertEquals('(descendant-or-self::p)[position()=last()-1]', Locator::elementAt('p', -2));
 }
開發者ID:janhenkgerritsen,項目名稱:Codeception,代碼行數:8,代碼來源:LocatorTest.php

示例2: testIsId

 public function testIsId()
 {
     $this->assertTrue(Locator::isID('#username'));
     $this->assertTrue(Locator::isID('#user.name'));
     $this->assertTrue(Locator::isID('#user-name'));
     $this->assertFalse(Locator::isID('#user-name .field'));
     $this->assertFalse(Locator::isID('.field'));
     $this->assertFalse(Locator::isID('hello'));
 }
開發者ID:corcre,項目名稱:elabftw,代碼行數:9,代碼來源:LocatorTest.php

示例3: loginAdminUserTest

 /**
  * Login the admin user using his email
  *
  * @param \AcceptanceTester $I
  */
 public function loginAdminUserTest(\AcceptanceTester $I)
 {
     $I->wantTo('log into the backend as Admin with email');
     $I->loginWithEmailAs($this->user['admin']);
     $this->saveLogin($I);
     $I->see('Dashboard');
     $I->see('Configuration', Locator::href('/bolt/users'));
     $I->see("You've been logged on successfully.");
 }
開發者ID:robbert-vdh,項目名稱:bolt,代碼行數:14,代碼來源:BackendAdminLoginWithEmailCest.php

示例4: loginAdminUserTest

 /**
  * Login the admin user using his email
  *
  * @param \AcceptanceTester $I
  */
 public function loginAdminUserTest(\AcceptanceTester $I)
 {
     $I->wantTo('log into the backend as Admin with email');
     $I->loginWithEmailAs($this->user['admin']);
     $this->cookies[$this->tokenNames['authtoken']] = $I->grabCookie($this->tokenNames['authtoken']);
     $this->cookies[$this->tokenNames['session']] = $I->grabCookie($this->tokenNames['session']);
     $I->see('Dashboard');
     $I->see('Configuration', Locator::href('/bolt/users'));
     $I->see("You've been logged on successfully.");
 }
開發者ID:atiarda,項目名稱:bolt,代碼行數:15,代碼來源:BackendAdminLoginWithEmailCest.php

示例5: testHumanReadableString

 public function testHumanReadableString()
 {
     $this->assertEquals("'string selector'", Locator::humanReadableString("string selector"));
     $this->assertEquals("css '.something'", Locator::humanReadableString(['css' => '.something']));
     $this->assertEquals("css selector '.something'", Locator::humanReadableString(WebDriverBy::cssSelector('.something')));
     try {
         Locator::humanReadableString(null);
         $this->fail("Expected exception when calling humanReadableString() with invalid selector");
     } catch (\InvalidArgumentException $e) {
     }
 }
開發者ID:hitechdk,項目名稱:Codeception,代碼行數:11,代碼來源:LocatorTest.php

示例6: fail

 protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null)
 {
     $selectorString = Locator::humanReadableString($selector);
     if (!$this->string) {
         throw new \PHPUnit_Framework_ExpectationFailedException("Element {$selectorString} was found", $comparisonFailure);
     }
     $output = "There was {$selectorString} element";
     $output .= $this->uriMessage("on page");
     $output .= str_replace($this->string, "<bold>{$this->string}</bold>", $this->nodesList($nodes, $this->string));
     $output .= "\ncontaining '{$this->string}'";
     throw new \PHPUnit_Framework_ExpectationFailedException($output, $comparisonFailure);
 }
開發者ID:solutionDrive,項目名稱:Codeception,代碼行數:12,代碼來源:WebDriverNot.php

示例7: testGetArguments

 public function testGetArguments()
 {
     $by = WebDriverBy::cssSelector('.something');
     $step = $this->getStep([null, [$by]]);
     $this->assertEquals('"' . Locator::humanReadableString($by) . '"', $step->getArguments(true));
     $step = $this->getStep([null, [['just', 'array']]]);
     $this->assertEquals('"just","array"', $step->getArguments(true));
     $step = $this->getStep([null, [function () {
     }]]);
     $this->assertEquals('"lambda function"', $step->getArguments(true));
     $step = $this->getStep([null, [[$this, 'testGetArguments']]]);
     $this->assertEquals('"callable function"', $step->getArguments(true));
 }
開發者ID:Marfuz,項目名稱:c4t_test,代碼行數:13,代碼來源:StepTest.php

示例8: testGetArguments

 public function testGetArguments()
 {
     $by = WebDriverBy::cssSelector('.something');
     $step = $this->getStep([null, [$by]]);
     $this->assertEquals('"' . Locator::humanReadableString($by) . '"', $step->getArgumentsAsString());
     $step = $this->getStep([null, [['just', 'array']]]);
     $this->assertEquals('["just","array"]', $step->getArgumentsAsString());
     $step = $this->getStep([null, [function () {
     }]]);
     $this->assertEquals('"Closure"', $step->getArgumentsAsString());
     $step = $this->getStep([null, [[$this, 'testGetArguments']]]);
     $this->assertEquals('["StepTest","testGetArguments"]', $step->getArgumentsAsString());
     $step = $this->getStep([null, [['PDO', 'getAvailableDrivers']]]);
     $this->assertEquals('["PDO","getAvailableDrivers"]', $step->getArgumentsAsString());
 }
開發者ID:solutionDrive,項目名稱:Codeception,代碼行數:15,代碼來源:StepTest.php

示例9: fail

 protected function fail($nodes, $selector, ComparisonFailure $comparisonFailure = null)
 {
     if (!count($nodes)) {
         throw new ElementNotFound($selector, 'Element located either by name, CSS or XPath');
     }
     $output = "Failed asserting that any element by " . Locator::humanReadableString($selector);
     $output .= $this->uriMessage('on page');
     if (count($nodes) < 5) {
         $output .= "\nElements: ";
         $output .= $this->nodesList($nodes);
     } else {
         $message = new Message("[total %s elements]");
         $output .= $message->with(count($nodes))->style('debug');
     }
     $output .= "\ncontains text '" . $this->string . "'";
     throw new \PHPUnit_Framework_ExpectationFailedException($output, $comparisonFailure);
 }
開發者ID:hitechdk,項目名稱:Codeception,代碼行數:17,代碼來源:WebDriver.php

示例10: createRecordsTest

 /**
  * Create a page record.
  *
  * @param \AcceptanceTester $I
  */
 public function createRecordsTest(\AcceptanceTester $I)
 {
     $I->wantTo("Create and edit Pages as the 'editor' user");
     // Set up the browser
     $I->setCookie('bolt_authtoken', $this->cookies['bolt_authtoken']);
     $I->setCookie('bolt_session', $this->cookies['bolt_session']);
     $I->amOnPage('/bolt');
     $I->see('New Page');
     $I->click('New Page');
     $I->see('Pages', Locator::href('/bolt/overview/pages'));
     $I->see('View Pages', Locator::href('/bolt/overview/pages'));
     $I->see('New Page', Locator::href('/bolt/editcontent/pages'));
     $I->fillField('#title', 'A page I made');
     $I->fillField('#teaser', 'Woop woop woop! Crazy nice stuff inside!');
     $I->fillField('#body', 'Take it, take it! I have three more of these!');
     $I->click('Save Page');
     $I->see('The new Page has been saved.');
     $I->see('A page I made');
     $I->see('Woop woop woop');
 }
開發者ID:aaleksu,項目名稱:bolt_cm,代碼行數:25,代碼來源:BackendEditorCest.php

示例11: test_default_non_editable_department_named_company

 public function test_default_non_editable_department_named_company(SuperUser $i)
 {
     $i->wantTo('Test if default "Company" named department is there and it is non editable');
     $i->login('management@xavoc.com');
     $i->clickMenu('HR->Department');
     $i->see('Company', Locator::elementAt('//table/tbody/tr/td', 1));
     $i->dontSeeElementInDOM('table tbody tr:first-child  td:last-child a');
     $i->wantTo('Test Quick Search');
     $i->searchFor('comp');
     $i->see('Company', Locator::elementAt('//table/tbody/tr/td', 1));
     $i->searchFor('xxxxssssss');
     $i->see('No matching records found');
     $i->searchFor('');
     $i->dontSee('No matching records found');
     $i->see('Company', Locator::elementAt('//table/tbody/tr/td', 1));
     $i->click('Active');
     $i->waitPageLoad();
     $i->click('InActive');
     $i->waitPageLoad();
 }
開發者ID:xavoctechnocratspvtltd,項目名稱:xepan2,代碼行數:20,代碼來源:hrCest.php

示例12: match

 /**
  * @param $page
  * @param $selector
  * @param bool $throwMalformed
  * @return array
  */
 protected function match($page, $selector, $throwMalformed = true)
 {
     if (is_array($selector)) {
         try {
             return $page->findElements($this->getStrictLocator($selector));
         } catch (InvalidSelectorException $e) {
             throw new MalformedLocatorException(key($selector) . ' => ' . reset($selector), "Strict locator");
         }
     }
     if ($selector instanceof WebDriverBy) {
         try {
             return $page->findElements($selector);
         } catch (InvalidSelectorException $e) {
             throw new MalformedLocatorException(sprintf("WebDriverBy::%s('%s')", $selector->getMechanism(), $selector->getValue()), 'WebDriver');
         }
     }
     $isValidLocator = false;
     $nodes = [];
     try {
         if (Locator::isID($selector)) {
             $isValidLocator = true;
             $nodes = $page->findElements(WebDriverBy::id(substr($selector, 1)));
         }
         if (empty($nodes) and Locator::isCSS($selector)) {
             $isValidLocator = true;
             $nodes = $page->findElements(WebDriverBy::cssSelector($selector));
         }
         if (empty($nodes) and Locator::isXPath($selector)) {
             $isValidLocator = true;
             $nodes = $page->findElements(WebDriverBy::xpath($selector));
         }
     } catch (InvalidSelectorException $e) {
         throw new MalformedLocatorException($selector);
     }
     if (!$isValidLocator and $throwMalformed) {
         throw new MalformedLocatorException($selector);
     }
     return $nodes;
 }
開發者ID:racinmat,項目名稱:SPETestParser,代碼行數:45,代碼來源:Acceptance.php

示例13: fileManagementViewEditTemplatesTest

 /**
  * Test the 'File management -> View / edit templates' interface
  *
  * @param \AcceptanceTester $I
  */
 public function fileManagementViewEditTemplatesTest(\AcceptanceTester $I)
 {
     $I->wantTo("Use the 'File management -> View / edit templates' interface as the 'developer' user");
     // Set up the browser
     $this->setLoginCookies($I);
     $I->amOnPage('/bolt/files/themes');
     // Inspect the landing page
     $dir = 'base-2016';
     $I->see('Create folder', Locator::find('a', ['href' => '#']));
     $I->see($dir, Locator::href("/bolt/files/themes/{$dir}"));
     $I->see("Rename {$dir}", Locator::find('a', ['href' => '#']));
     $I->see("Delete {$dir}", Locator::find('a', ['href' => '#']));
     // Navigate into the theme and check the results
     $I->click("{$dir}", Locator::href("/bolt/files/themes/{$dir}"));
     $I->see('css', Locator::href("/bolt/files/themes/{$dir}/css"));
     $I->see('images', Locator::href("/bolt/files/themes/{$dir}/images"));
     $I->see('js', Locator::href("/bolt/files/themes/{$dir}/js"));
     $I->see('theme.yml', Locator::href("/bolt/file/edit/themes/{$dir}/theme.yml"));
     $I->see('record.twig', Locator::href("/bolt/file/edit/themes/{$dir}/record.twig"));
     $I->see('index.twig', Locator::href("/bolt/file/edit/themes/{$dir}/index.twig"));
     // Navigate into a subdirectory
     $I->click('css', Locator::href("/bolt/files/themes/{$dir}/css"));
     $I->see('theme.css', Locator::href("/bolt/file/edit/themes/{$dir}/css/theme.css"));
 }
開發者ID:bolt,項目名稱:bolt,代碼行數:29,代碼來源:BackendDeveloperCest.php

示例14: filterByXPath

 /**
  * @param $locator
  * @return Crawler
  */
 protected function filterByXPath($locator)
 {
     if (!Locator::isXPath($locator)) {
         throw new MalformedLocatorException($locator, 'xpath');
     }
     return $this->getCrawler()->filterXPath($locator);
 }
開發者ID:vladislavl-hyuna,項目名稱:crmapp,代碼行數:11,代碼來源:InnerBrowser.php

示例15: 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');
 }
開發者ID:lenninsanchez,項目名稱:donadores,代碼行數:20,代碼來源:Mink.php


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