本文整理汇总了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());
}
示例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');
}
示例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')));
}
示例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);
}
示例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);
}
示例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());
}
示例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;
}
示例8: getUsers
private function getUsers()
{
return $this->webDriver->findElements(WebDriverBy::className("user"));
}
示例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++;
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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());
}
示例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();