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


PHP WebDriverBy::className方法代码示例

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


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

示例1: User

 function test1()
 {
     $user = new User();
     $user->setEmail("test@example.com");
     $user->setUsername("test");
     $user->setPassword("ouhosu");
     $this->em->persist($user);
     $tree = new Tree();
     $tree->setTitleAdmin('Tree');
     $tree->setPublicId('tree');
     $tree->setOwner($user);
     $this->em->persist($tree);
     $treeVersion = new TreeVersion();
     $treeVersion->setTree($tree);
     $treeVersion->setPublicId('version');
     $treeVersion->setFeatureLibraryContent(true);
     $this->em->persist($treeVersion);
     $startNode = new Node();
     $startNode->setTreeVersion($treeVersion);
     $startNode->setTitle("START HERE");
     $startNode->setPublicId('start');
     $this->em->persist($startNode);
     $libraryContent = new LibraryContent();
     $libraryContent->setTreeVersion($treeVersion);
     $libraryContent->setBodyText('TREE CONTENT');
     $this->em->persist($libraryContent);
     $nodeHasLibraryContent = new NodeHasLibraryContent();
     $nodeHasLibraryContent->setSort(0);
     $nodeHasLibraryContent->setNode($startNode);
     $nodeHasLibraryContent->setLibraryContent($libraryContent);
     $this->em->persist($nodeHasLibraryContent);
     $treeVersionPublished = new TreeVersionPublished();
     $treeVersionPublished->setTreeVersion($treeVersion);
     $treeVersionPublished->setPublishedBy($user);
     $this->em->flush();
     $tvsn = new TreeVersionStartingNode();
     $tvsn->setNode($startNode);
     $tvsn->setTreeVersion($treeVersion);
     $this->em->persist($tvsn);
     $published = new TreeVersionPublished();
     $published->setTreeVersion($treeVersion);
     $this->em->persist($published);
     $this->em->flush();
     // ######################################################## LOAD PAGE
     $this->driver->get('http://localhost/app_dev.php/tree/tree/demo');
     $startLink = $this->driver->findElement(WebDriverBy::id('StartTreeLink'));
     $this->assertEquals('Start Tree!', $startLink->getText());
     // ######################################################## Start Tree
     $startLink->click();
     sleep($this->sleepOnActionWithNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('START HERE', $nodeTitle->getText());
     $nodeBody = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('body'));
     $this->assertEquals('TREE CONTENT', $nodeBody->getText());
 }
开发者ID:QuestionKey,项目名称:QuestionKey-Core,代码行数:55,代码来源:LibraryContentTest.php

示例2: testWebDriverByLocators

 public function testWebDriverByLocators()
 {
     $this->module->amOnPage('/login');
     $this->module->seeElement(WebDriverBy::id('submit-label'));
     $this->module->seeElement(WebDriverBy::name('password'));
     $this->module->seeElement(WebDriverBy::className('optional'));
     $this->module->seeElement(WebDriverBy::cssSelector('form.global_form_box'));
     $this->module->seeElement(WebDriverBy::xpath(\Codeception\Util\Locator::tabIndex(4)));
     $this->module->fillField(WebDriverBy::name('password'), '123456');
     $this->module->amOnPage('/form/select');
     $this->module->selectOption(WebDriverBy::name('age'), 'child');
     $this->module->amOnPage('/form/checkbox');
     $this->module->checkOption(WebDriverBy::name('terms'));
     $this->module->amOnPage('/');
     $this->module->seeElement(WebDriverBy::linkText('Test'));
     $this->module->click(WebDriverBy::linkText('Test'));
     $this->module->seeCurrentUrlEquals('/form/hidden');
 }
开发者ID:surjit,项目名称:Codeception,代码行数:18,代码来源:WebDriverTest.php

示例3: testPageHas25Items

 /**
  * Page has 25 items.
  */
 public function testPageHas25Items()
 {
     $this->webDriver->get('https://github.com/trending?l=php');
     self::assertCount(25, $this->webDriver->findElements(WebDriverBy::className('repo-list-item')));
 }
开发者ID:serbanghita,项目名称:Selenium-Setup-Webdriver,代码行数:8,代码来源:ChromeTest.php

示例4: expectsToBeSelectedByClassName

 /**
  * Client expects that an element is selected by the given class name.
  * Returns true when the element is selected and false otherwise.
  * Retry the process two times or until the attempts argument count
  * is reached when a stale element reference exception is thrown.
  * Recommended usage in web driver waits.
  *
  * @param string $className Class name of expected element.
  * @param int    $attempts  (Optional) Attempts until the method will fail and return false.
  *
  * @return bool
  */
 public function expectsToBeSelectedByClassName($className, $attempts = 2)
 {
     if ($this->isFailed()) {
         return false;
     }
     $by = WebDriverBy::className($className);
     return $this->expectsToBeSelected($by, $attempts);
 }
开发者ID:AlcyZ,项目名称:GX-Selenium-Framework,代码行数:20,代码来源:InspectionProviderTrait.php

示例5: getArrayByClassName

 /**
  * Returns an element by the given class name.
  * If nothing is found, an empty array will be returned.
  *
  * @param string $className Class name of expected element.
  * @param int    $attempts  Attempts until the method will fail and return false.
  *
  * @return WebDriverElement[]|array
  */
 public function getArrayByClassName($className, $attempts = 2)
 {
     if ($this->isFailed()) {
         return [];
     }
     $by = WebDriverBy::className($className);
     return $this->getArrayBy($by, $attempts);
 }
开发者ID:AlcyZ,项目名称:GX-Selenium-Framework,代码行数:17,代码来源:ElementProviderTrait.php

示例6: testNoPoints

 function testNoPoints()
 {
     // ######################################################## LOAD PAGE
     $this->driver->get('http://localhost/app_dev.php/tree/tree/demo');
     $startLink = $this->driver->findElement(WebDriverBy::id('StartTreeLink'));
     $this->assertEquals('Start Tree!', $startLink->getText());
     // ######################################################## Start Tree
     $startLink->click();
     sleep($this->sleepOnActionWithNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('START HERE', $nodeTitle->getText());
     // ######################################################## Click Points
     $elements = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElements(WebDriverBy::className('option'));
     $elements[2]->click();
     $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::cssSelector('input[type="submit"]'))->click();
     sleep($this->sleepOnActionNoNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('END HERE', $nodeTitle->getText());
     $nodeBody = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('body'));
     $this->assertEquals('NO POINTS', $nodeBody->getText());
 }
开发者ID:QuestionKey,项目名称:QuestionKey-Core,代码行数:21,代码来源:LibraryContentAndVariableTest.php

示例7: getOrganisationsByRubric

 /**
  * Получить список организаций в категории
  * @param string $cityHref Ссылка на страницу города
  * @param string $rubricName Название рубрики
  * @param string $rubricId Id рубрики
  * @return array
  */
 public function getOrganisationsByRubric($cityHref, $rubricName, $rubricId)
 {
     $rubricName = urlencode($rubricName);
     $this->driver->get("{$cityHref}/search/{$rubricName}/rubricId/{$rubricId}");
     $results = [];
     //Особенность 2гис - элементы рендерят вначале несколько раз, ждем пока не зарендерятся
     sleep(1);
     $organisationList = $this->driver->findElements(WebDriverBy::className('mixedResults'));
     if (isset($organisationList[0])) {
         $organisations = $organisationList[0]->findElements(WebDriverBy::className('miniCard'));
         foreach ($organisations as $organisation) {
             $organisation->click();
             //Ждем появления карточки организации
             $this->driver->wait(5, 500)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::className('firmCard')));
             $firmCard = $this->driver->findElements(WebDriverBy::className('firmCard'));
             if (isset($firmCard[0])) {
                 $results[] = $this->extractDataFromFirmCard($firmCard[0]);
             }
         }
     } else {
         //Если списка организаций нет - проверяем наличие карточки организации
         $firmCard = $this->driver->findElements(WebDriverBy::className('firmCard'));
         if (isset($firmCard[0])) {
             $results[] = $this->extractDataFromFirmCard($firmCard[0]);
         }
     }
     return $results;
 }
开发者ID:avin,项目名称:selenium-parser,代码行数:35,代码来源:Parser2GIS.php

示例8: getUsers

 private function getUsers()
 {
     return $this->webDriver->findElements(WebDriverBy::className("user"));
 }
开发者ID:amyboyd,项目名称:overwatch,代码行数:4,代码来源:EditGroupTest.php

示例9: Exception

    echo $e->getTraceAsString() . PHP_EOL;
    print "[view_car_details:2] Missing car anchor tag." . PHP_EOL;
    $f++;
}
try {
    if (!isset($element)) {
        throw new Exception();
    }
    $element->click();
    $s++;
} catch (Exception $e) {
    print "[view_car_details:3] Cannot click element." . PHP_EOL;
    $f++;
}
try {
    $driver->wait(10, 500)->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::className("jumbotron")));
    $s++;
} catch (Exception $e) {
    print "[view_car_details:4] Never loaded page with jumbotron." . PHP_EOL;
    $f++;
}
try {
    $elements = $driver->findElements(WebDriverBy::cssSelector(".jumbotron label"));
    $text = trim($elements[0]->getText());
    if (strpos($text, "Number of Passengers:") == -1) {
        throw new Exception();
    }
    $s++;
} catch (Exception $e) {
    print "[view_car_details:5] Passenger text missing." . PHP_EOL;
    $f++;
开发者ID:richwandell,项目名称:Codeigniter-Example-App,代码行数:31,代码来源:view_car_details.php

示例10: expectSelectVisibleTextByClassName

 /**
  * Expects to select an elements option by visible text and the elements class name.
  * Retry the process two times or until the attempts argument count
  * is reached when a exception is thrown.
  * Returns false when the web driver was unable to select the expected element.
  *
  * @param string $className   Class name of expected element.
  * @param int    $visibleText VisibleText of option to be selected.
  * @param int    $attempts    Amount of retries until the operation will fail.
  *
  * @return bool True if the elements visibleText is selected, false otherwise.
  */
 public function expectSelectVisibleTextByClassName($className, $visibleText, $attempts = 2)
 {
     if ($this->isFailed()) {
         return false;
     }
     $by = WebDriverBy::className($className);
     return $this->expectSelectVisibleTextByElement($by, $visibleText, $attempts);
 }
开发者ID:AlcyZ,项目名称:GX-Selenium-Framework,代码行数:20,代码来源:SelectingProviderTrait.php

示例11: waitUntilClassNameIsEnabled

 /**
  * Wait until an element is enabled by the given class name or the value of the timeout argument is achieved.
  *
  * @param int $className Class name of expected element.
  * @param int $timeOut   Timeout to wait, when the amount (in seconds) is reached, the test case fails.
  * @param int $interval  Interval of repeating the waiting condition.
  *
  * @return $this Same instance for chained method calls.
  */
 public function waitUntilClassNameIsEnabled($className, $timeOut = 30, $interval = 250)
 {
     if ($this->isFailed()) {
         return $this;
     }
     $by = WebDriverBy::className($className);
     return $this->waitUntilElementIsEnabled($by, $timeOut, $interval);
 }
开发者ID:AlcyZ,项目名称:GX-Selenium-Framework,代码行数:17,代码来源:WaitProviderTrait.php

示例12: getPremiumKey

 /**
  * Получить список доступных городов
  */
 public function getPremiumKey()
 {
     $this->driver->get("http://www.di.fm");
     $email = 'iwantsomeshit' . time() . '@gmail.com';
     $password = 'supersecret';
     //Wait register button
     $signUpButton = false;
     while (!$signUpButton) {
         try {
             $signUpButton = $this->driver->findElement(WebDriverBy::className('signup'));
         } catch (WebDriverException $exception) {
             usleep(200);
         }
     }
     $signUpButton->click();
     //Fill form
     $emailField = $this->driver->findElement(WebDriverBy::id('member_email'));
     while (!$emailField->isDisplayed()) {
         usleep(200);
     }
     $emailField->click();
     $this->driver->getKeyboard()->sendKeys($email);
     $this->driver->findElement(WebDriverBy::id('member_password'))->click();
     $this->driver->getKeyboard()->sendKeys($password);
     $this->driver->findElement(WebDriverBy::id('member_password_confirmation'))->click();
     $this->driver->getKeyboard()->sendKeys($password);
     $this->driver->findElement(WebDriverBy::xpath("//button[contains(.,'Create Free Account')]"))->click();
     //Wait user-panel button
     $userButton = false;
     while (!$userButton) {
         try {
             $userButton = $this->driver->findElement(WebDriverBy::className("user-name"));
         } catch (WebDriverException $exception) {
             usleep(200);
         }
     }
     //Activate trial
     $this->driver->get("http://www.di.fm/member/premium/trial/activate");
     //Wait user-panel button
     $userType = false;
     //user-name
     while (!$userType) {
         try {
             $userType = $this->driver->findElement(WebDriverBy::xpath("//span[contains(.,'Premium Member')]"));
         } catch (WebDriverException $exception) {
             usleep(200);
         }
     }
     $this->driver->get("http://www.di.fm/settings");
     //Get key from settings page
     $key = false;
     while (!$key) {
         try {
             $key = $this->driver->findElement(WebDriverBy::className("listen-key"));
         } catch (WebDriverException $exception) {
             usleep(200);
         }
     }
     $keyValue = $key->getText();
     return $keyValue;
 }
开发者ID:avin,项目名称:selenium-parser,代码行数:64,代码来源:PremiumDiRadio.php

示例13: verifyRegexByClassName

 /**
  * Verify an element with a regular expression by class name.
  * Retry the process two times or until the attempts argument count
  * is reached when an exception is thrown.
  *
  * @param string $className Class name of expected element.
  * @param string $regex     Regular expression to compare with.
  * @param string $type      Verification type (elements text, attributes ...).
  * @param int    $attempts  Attempts until the method will fail and return false.
  *
  * @see VerificationTrait::_validateTypeArgument
  * @return bool
  */
 public function verifyRegexByClassName($className, $regex, $type, $attempts = 2)
 {
     if ($this->isFailed()) {
         return false;
     }
     $by = WebDriverBy::className($className);
     return $this->_verifyBy($by, $regex, $type, $attempts, true);
 }
开发者ID:AlcyZ,项目名称:GX-Selenium-Framework,代码行数:21,代码来源:VerificationTrait.php

示例14: testGoBackByClickingReset

 function testGoBackByClickingReset()
 {
     $user = new User();
     $user->setEmail("test@example.com");
     $user->setUsername("test");
     $user->setPassword("ouhosu");
     $this->em->persist($user);
     $tree = new Tree();
     $tree->setTitleAdmin('Tree');
     $tree->setPublicId('tree');
     $tree->setOwner($user);
     $this->em->persist($tree);
     $treeVersion = new TreeVersion();
     $treeVersion->setTree($tree);
     $treeVersion->setPublicId('version');
     $this->em->persist($treeVersion);
     $startNode = new Node();
     $startNode->setTreeVersion($treeVersion);
     $startNode->setTitle("START HERE");
     $startNode->setPublicId('start');
     $this->em->persist($startNode);
     $endNode = new Node();
     $endNode->setTreeVersion($treeVersion);
     $endNode->setTitle("END HERE");
     $endNode->setPublicId('end');
     $this->em->persist($endNode);
     $nodeOption = new NodeOption();
     $nodeOption->setTitle("LETS GO HERE");
     $nodeOption->setTreeVersion($treeVersion);
     $nodeOption->setNode($startNode);
     $nodeOption->setDestinationNode($endNode);
     $nodeOption->setPublicId('option');
     $this->em->persist($nodeOption);
     $treeVersionPublished = new TreeVersionPublished();
     $treeVersionPublished->setTreeVersion($treeVersion);
     $treeVersionPublished->setPublishedBy($user);
     $this->em->flush();
     $tvsn = new TreeVersionStartingNode();
     $tvsn->setNode($startNode);
     $tvsn->setTreeVersion($treeVersion);
     $this->em->persist($tvsn);
     $published = new TreeVersionPublished();
     $published->setTreeVersion($treeVersion);
     $this->em->persist($published);
     $this->em->flush();
     // ######################################################## LOAD PAGE
     $this->driver->get('http://localhost/app_dev.php/tree/tree/demo');
     $startLink = $this->driver->findElement(WebDriverBy::id('StartTreeLink'));
     $this->assertEquals('Start Tree!', $startLink->getText());
     // ######################################################## Start Tree
     $startLink->click();
     sleep($this->sleepOnActionWithNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('START HERE', $nodeTitle->getText());
     // ######################################################## LOAD PAGE
     $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElements(WebDriverBy::className('option'))[0]->click();
     $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::cssSelector('input[type="submit"]'))->click();
     sleep($this->sleepOnActionNoNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('END HERE', $nodeTitle->getText());
     // ######################################################## GO BACK
     $this->driver->findElement(WebDriverBy::className('restart'))->findElement(WebDriverBy::tagName('a'))->click();
     sleep($this->sleepOnActionNoNetwork);
     $nodeTitle = $this->driver->findElement(WebDriverBy::id('DemoHere'))->findElement(WebDriverBy::className('node'))->findElement(WebDriverBy::className('title'));
     $this->assertEquals('START HERE', $nodeTitle->getText());
 }
开发者ID:QuestionKey,项目名称:QuestionKey-Core,代码行数:66,代码来源:BasicTreeTest.php

示例15:

namespace Facebook\WebDriver;

use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
require_once 'vendor/autoload.php';
// start Firefox with 5 second timeout
$host = 'http://localhost:4444/wd/hub';
// this is the default
$capabilities = DesiredCapabilities::firefox();
$driver = RemoteWebDriver::create($host, $capabilities, 5000);
// navigate to 'http://docs.seleniumhq.org/'
$driver->get('http://docs.seleniumhq.org/');
// adding cookie
$driver->manage()->deleteAllCookies();
$driver->manage()->addCookie(array('name' => 'cookie_name', 'value' => 'cookie_value'));
$cookies = $driver->manage()->getCookies();
print_r($cookies);
// click the link 'About'
$link = $driver->findElement(WebDriverBy::id('menu_about'));
$link->click();
// print the title of the current page
echo "The title is '" . $driver->getTitle() . "'\n";
// print the URI of the current page
echo "The current URI is '" . $driver->getCurrentURL() . "'\n";
// Search 'php' in the search box
$input = $driver->findElement(WebDriverBy::id('q'));
$input->sendKeys('php')->submit();
// wait at most 10 seconds until at least one result is shown
$driver->wait(10)->until(WebDriverExpectedCondition::presenceOfAllElementsLocatedBy(WebDriverBy::className('gsc-result')));
// close the Firefox
$driver->quit();
开发者ID:vladislavl-hyuna,项目名称:crmapp,代码行数:31,代码来源:example.php


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