当前位置: 首页>>代码示例>>PHP>>正文


PHP Locator::combine方法代码示例

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


在下文中一共展示了Locator::combine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCombine

 public function testCombine()
 {
     $result = Locator::combine('//button[@value="Click Me"]', '//a[.="Click Me"]');
     $this->assertEquals('//button[@value="Click Me"] | //a[.="Click Me"]', $result);
     $result = Locator::combine('button[value="Click Me"]', '//a[.="Click Me"]');
     $this->assertEquals('descendant-or-self::button[@value = \'Click Me\'] | //a[.="Click Me"]', $result);
     $xml = new SimpleXMLElement("<root><button value='Click Me' /></root>");
     $this->assertNotEmpty($xml->xpath($result));
     $xml = new SimpleXMLElement("<root><a href='#'>Click Me</a></root>");
     $this->assertNotEmpty($xml->xpath($result));
 }
开发者ID:corcre,项目名称:elabftw,代码行数:11,代码来源:LocatorTest.php

示例2: findCheckable

 /**
  * @param $context
  * @param $radioOrCheckbox
  * @param bool $byValue
  * @return mixed|null
  */
 protected function findCheckable($context, $radioOrCheckbox, $byValue = false)
 {
     if ($radioOrCheckbox instanceof WebDriverElement) {
         return $radioOrCheckbox;
     }
     if (is_array($radioOrCheckbox) or $radioOrCheckbox instanceof WebDriverBy) {
         return $this->matchFirstOrFail($this->webDriver, $radioOrCheckbox);
     }
     $locator = Crawler::xpathLiteral($radioOrCheckbox);
     if ($context instanceof WebDriverElement && $context->getTagName() === 'input') {
         $contextType = $context->getAttribute('type');
         if (!in_array($contextType, ['checkbox', 'radio'], true)) {
             return null;
         }
         $nameLiteral = Crawler::xPathLiteral($context->getAttribute('name'));
         $typeLiteral = Crawler::xPathLiteral($contextType);
         $inputLocatorFragment = "input[@type = {$typeLiteral}][@name = {$nameLiteral}]";
         $xpath = Locator::combine("ancestor::form//{$inputLocatorFragment}[(@id = ancestor::form//label[contains(normalize-space(string(.)), {$locator})]/@for) or @placeholder = {$locator}]", "ancestor::form//label[contains(normalize-space(string(.)), {$locator})]//{$inputLocatorFragment}");
         if ($byValue) {
             $xpath = Locator::combine($xpath, "ancestor::form//{$inputLocatorFragment}[@value = {$locator}]");
         }
     } else {
         $xpath = Locator::combine("//input[@type = 'checkbox' or @type = 'radio'][(@id = //label[contains(normalize-space(string(.)), {$locator})]/@for) or @placeholder = {$locator}]", "//label[contains(normalize-space(string(.)), {$locator})]//input[@type = 'radio' or @type = 'checkbox']");
         if ($byValue) {
             $xpath = Locator::combine($xpath, "//input[@type = 'checkbox' or @type = 'radio'][@value = {$locator}]");
         }
     }
     $els = $context->findElements(WebDriverBy::xpath($xpath));
     if (count($els)) {
         return reset($els);
     }
     $els = $context->findElements(WebDriverBy::xpath(str_replace('ancestor::form', '', $xpath)));
     if (count($els)) {
         return reset($els);
     }
     $els = $this->match($context, $radioOrCheckbox);
     if (count($els)) {
         return reset($els);
     }
     return null;
 }
开发者ID:neronmoon,项目名称:Codeception,代码行数:47,代码来源:WebDriver.php

示例3: findCheckable

 /**
  * @param $context
  * @param $radio_or_checkbox
  * @param bool $byValue
  * @return mixed|null
  */
 protected function findCheckable($context, $radio_or_checkbox, $byValue = false)
 {
     if ($radio_or_checkbox instanceof \WebDriverElement) {
         return $radio_or_checkbox;
     }
     if (is_array($radio_or_checkbox) or $radio_or_checkbox instanceof \WebDriverBy) {
         return $this->matchFirstOrFail($this->webDriver, $radio_or_checkbox);
     }
     $locator = Crawler::xpathLiteral($radio_or_checkbox);
     $xpath = Locator::combine("//input[./@type = 'checkbox'][(./@id = //label[contains(normalize-space(string(.)), {$locator})]/@for) or ./@placeholder = {$locator}]", "//label[contains(normalize-space(string(.)), {$locator})]//.//input[./@type = 'checkbox']", "//input[./@type = 'radio'][(./@id = //label[contains(normalize-space(string(.)), {$locator})]/@for) or ./@placeholder = {$locator}]", "//label[contains(normalize-space(string(.)), {$locator})]//.//input[./@type = 'radio']");
     if ($byValue) {
         $xpath = Locator::combine($xpath, "//input[./@type = 'checkbox'][./@value = {$locator}]", "//input[./@type = 'radio'][./@value = {$locator}]");
     }
     /** @var $context \WebDriverElement  * */
     $els = $context->findElements(\WebDriverBy::xpath($xpath));
     if (count($els)) {
         return reset($els);
     }
     $els = $this->match($context, $radio_or_checkbox);
     if (count($els)) {
         return reset($els);
     }
     return null;
 }
开发者ID:Eli-TW,项目名称:Codeception,代码行数:30,代码来源:WebDriver.php

示例4: AcceptanceTester

<?php

use Codeception\Util\Locator;
$I = new AcceptanceTester($scenario);
$I->am('Any user');
$I->wantTo('do a login on the web application');
$I->lookForwardTo('access all features that my access level grant');
$I->amOnPage('/');
$I->fillField(Locator::combine('//*[@data-qa="auth-login"]', '//input[@data-qa="auth-login"]'), 'sbsuporte@socialbase.com.br');
$I->fillField(['xpath' => '//*[@data-qa="auth-pass"]'], 'socialbase');
$I->click(['xpath' => '//button[@data-qa="auth-button"]']);
$I->see('SB Suporte', ['xpath' => '//div[@data-qa="profile-my-name"]']);
$I->see('CARGO', ['xpath' => '//div[@data-qa="profile-my-job"]']);
开发者ID:yurireeis,项目名称:CodeCeptionTest,代码行数:13,代码来源:SigninCept.php


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