• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Util\Locator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Codeception\Util\Locator的典型用法代码示例。如果您正苦于以下问题:PHP Locator类的具体用法?PHP Locator怎么用?PHP Locator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Locator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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('[email protected]');
     $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


示例16: testGetArguments

 public function testGetArguments()
 {
     $by = WebDriverBy::cssSelector('.something');
     $step = $this->getMockBuilder('\\Codeception\\Step')->setConstructorArgs([null, [$by]])->setMethods(null)->getMock();
     $this->assertEquals('"' . Locator::humanReadableString($by) . '"', $step->getArguments(true));
 }
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:6,代码来源:StepTest.php


示例17: stringifyArgument

 protected function stringifyArgument($argument)
 {
     if (is_string($argument)) {
         return '"' . strtr($argument, ["\n" => '\\n', "\r" => '\\r', "\t" => ' ']) . '"';
     } elseif (is_resource($argument)) {
         $argument = (string) $argument;
     } elseif (is_array($argument)) {
         foreach ($argument as $key => $value) {
             if (is_object($value)) {
                 $argument[$key] = $this->getClassName($value);
             }
         }
     } elseif (is_object($argument)) {
         if (method_exists($argument, '__toString')) {
             $argument = (string) $argument;
         } elseif (get_class($argument) == 'Facebook\\WebDriver\\WebDriverBy') {
             $argument = Locator::humanReadableString($argument);
         } else {
             $argument = $this->getClassName($argument);
         }
     }
     return json_encode($argument, JSON_UNESCAPED_UNICODE);
 }
开发者ID:janhenkgerritsen,项目名称:Codeception,代码行数:23,代码来源:Step.php


示例18: testStrictLocators

 public function testStrictLocators()
 {
     $this->module->amOnPage('/login');
     $this->module->seeElement(['id' => 'submit-label']);
     $this->module->seeElement(['name' => 'password']);
     $this->module->seeElement(['class' => 'optional']);
     $this->module->seeElement(['css' => 'form.global_form_box']);
     $this->module->seeElement(['xpath' => \Codeception\Util\Locator::tabIndex(4)]);
     $this->module->fillField(['name' => 'password'], '123456');
     $this->module->amOnPage('/form/select');
     $this->module->selectOption(['name' => 'age'], 'child');
     $this->module->amOnPage('/form/checkbox');
     $this->module->checkOption(['name' => 'terms']);
     $this->module->amOnPage('/');
     $this->module->seeElement(['link' => 'Test']);
     $this->module->click(['link' => 'Test']);
     $this->module->seeCurrentUrlEquals('/form/hidden');
 }
开发者ID:augustus-amalejo,项目名称:palittayo,代码行数:18,代码来源:TestsForWeb.php


示例19: match

    protected function match($selector)
    {
        try {
            $selector = CssSelector::toXPath($selector);
        } catch (ParseException $e) {
        }
        if (!Locator::isXPath($selector)) return null;

        return @$this->crawler->filterXPath($selector);
    }
开发者ID:hendryguna,项目名称:laravel-basic,代码行数:10,代码来源:Framework.php


示例20: AcceptanceTester

    $I->see('Test plant latin', 'tr td');
}
$I = new AcceptanceTester($scenario);
$I->wantTo('Edit plant');
/*
 * The user creates a plant width all the information on a plant.
 */
helperCreatePlant($I);
/*
 * He is now on the front page and he wants to edit the newly created plant.
 */
$plantID = $I->grabRecord('plants', array('name' => 'Test plant'))->id;
/*
 * He clicks on the link "mere.." at the plant.
 */
$I->click('Mere..', Locator::href('/plant-detail/' . $plantID));
/*
 * Here he sees all the information on the plant has been saved correct.
 */
$I->seeInCurrentUrl('plant-detail/' . $plantID);
/*
 * Now he clicks on the edit button for the plant.
 */
$I->click('edit plant');
/*
 * The page redirects him to the edit page
 */
$I->seeInCurrentUrl('show-edit-plant');
/*
 * Here he sees all the checkboxes is checked correctly.
 */
开发者ID:Opstrup,项目名称:naturens_spisekammer,代码行数:31,代码来源:EditPlantTestCept.php



注:本文中的Codeception\Util\Locator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Util\Stub类代码示例发布时间:2022-05-23
下一篇:
PHP Util\Fixtures类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap