當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。