本文整理汇总了PHP中WebDriverBy::xpath方法的典型用法代码示例。如果您正苦于以下问题:PHP WebDriverBy::xpath方法的具体用法?PHP WebDriverBy::xpath怎么用?PHP WebDriverBy::xpath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebDriverBy
的用法示例。
在下文中一共展示了WebDriverBy::xpath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fillSeeDeleteInputField
/**
* @param RemoteWebElement $fieldContext
* @param array $testValues An array of arrays that contains the values to validate.
* * First value is the input value
* * second value is the value that is expected after the validation
* * optional third value is the "internal" value like required for date fields (value is internally
* represented by a timestamp). If this value is not defined the second value will be used.
* Example for field with alpha validation: [['foo', 'foo'], ['bar1'], ['bar']]
* Example for field with date validation: [['29-01-2016', '29-01-2016', '1454025600']]
*/
public function fillSeeDeleteInputField(RemoteWebElement $fieldContext, array $testValues)
{
$I = $this->tester;
$I->wantTo('Fill field, check the fieldvalue after evaluation and delete the value.');
$inputField = $fieldContext->findElement(\WebDriverBy::xpath('.//*/input[@data-formengine-input-name]'));
$internalInputField = $fieldContext->findElement(\WebDriverBy::xpath('.//*/input[@name="' . $inputField->getAttribute('data-formengine-input-name') . '"]'));
foreach ($testValues as $comment => $testValue) {
if (!empty($comment)) {
$I->comment($comment);
}
$I->comment('Fill the field and switch focus to trigger validation.');
$I->fillField($inputField, $testValue[0]);
// change the focus to trigger validation
$fieldContext->sendKeys("\n");
$I->comment('Test value of "visible" field');
$I->canSeeInField($inputField, $testValue[1]);
$I->comment('Test value of the internal field');
$I->canSeeInField($internalInputField, isset($testValue[2]) ? $testValue[2] : $testValue[1]);
}
$inputField->findElement(\WebDriverBy::xpath('parent::*/button[@class="close"]'))->click();
// change the context from the field
$fieldContext->sendKeys("\n");
$I->canSeeInField($inputField, '');
$I->canSeeInField($internalInputField, '');
}
示例2: testProcessOrder
public function testProcessOrder()
{
$this->driver->get($this->getTestPath('/admin'));
$this->driver->findElement(WebDriverBy::id('username'))->sendKeys('admin');
$this->driver->findElement(WebDriverBy::id('login'))->sendKeys('P@ssw0rd');
$this->driver->findElement(WebDriverBy::className('form-button'))->click();
$this->driver->findElement(WebDriverBy::xpath("//span[text()='Sales']"))->click();
$this->driver->findElement(WebDriverBy::xpath("//span[text()='Orders']"))->click();
$this->driver->wait()->until(WebDriverExpectedCondition::presenceOfElementLocated(WebDriverBy::id('sales_order_grid_filter_real_order_id')));
$this->driver->findElement(WebDriverBy::id('sales_order_grid_filter_real_order_id'))->sendKeys('ICANN-D10000014');
$this->driver->findElement(WebDriverBy::id('sales_order_grid_filter_real_order_id'))->sendKeys(WebDriverKeys::ENTER);
sleep(3);
$this->driver->findElement(WebDriverBy::xpath("//html/body/div[1]/div[2]/div/div[3]/div/div[2]/div/table/tbody/tr[1]/td[2]"))->click();
$this->driver->findElement(WebDriverBy::xpath("//span[text()='Invoice']"))->click();
$this->driver->findElement(WebDriverBy::xpath("//span[text()='Submit Invoice']"))->click();
$this->driver->findElement(WebDriverBy::xpath("//span[text()='Ship']"))->click();
$this->driver->findElement(WebDriverBy::xpath("//span[text()='Add Tracking Number']"))->click();
$this->driver->findElement(WebDriverBy::id("trackingC1"))->click();
$this->driver->findElement(WebDriverBy::xpath("//select[@id='trackingC1']/option[@value='fedex']"))->click();
$this->driver->findElement(WebDriverBy::id("trackingT1"))->sendKeys('FEDEX');
$this->driver->findElement(WebDriverBy::id("trackingN1"))->sendKeys('Tracking0001');
$this->driver->findElement(WebDriverBy::id("send_email"))->click();
$this->driver->findElement(WebDriverBy::xpath("//span[text()='Submit Shipment']"))->click();
sleep(5);
}
示例3: testShouldPersistNoSizes
public function testShouldPersistNoSizes()
{
$elements = self::$driver->findElements(WebDriverBy::xpath('//input[@type="checkbox" and starts-with(@name, "tinypng_sizes") and @checked="checked"]'));
foreach ($elements as $element) {
$element->click();
}
self::$driver->findElement(WebDriverBy::tagName('form'))->submit();
$elements = self::$driver->findElements(WebDriverBy::xpath('//input[@type="checkbox" and starts-with(@name, "tinypng_sizes") and @checked="checked"]'));
$this->assertEquals(0, count(array_map('elementName', $elements)));
}
示例4: testShouldPersistSizes
public function testShouldPersistSizes()
{
$element = self::$driver->findElement(WebDriverBy::id('tinypng_sizes_medium'));
$element->click();
self::$driver->findElement(WebDriverBy::tagName('form'))->submit();
$elements = self::$driver->findElements(WebDriverBy::xpath('//input[@type="checkbox" and starts-with(@name, "tinypng_sizes") and @checked="checked"]'));
$size_ids = array_map('elementName', $elements);
$this->assertContains('tinypng_sizes[thumbnail]', $size_ids);
$this->assertNotContains('tinypng_sizes[medium]', $size_ids);
$this->assertContains('tinypng_sizes[large]', $size_ids);
}
示例5: _validateSessionTableContents
/**
* Checks the contents of the session table and compares it against an expected
* result.
*
* @param array $expectedSessions list of all the expected sessions.
*
* @return void
*/
private function _validateSessionTableContents($expectedSessions)
{
$sessionTable = $this->webDriver->findElements(WebDriverBy::ClassName('dynamictable'));
$actualSessions = $sessionTable[1]->findElements(WebDriverBy::xpath('.//tbody//tr'));
$this->assertEquals(count($actualSessions), count($expectedSessions), "Number of visits should be " . count($expectedSessions) . ", not " . count($actualSessions));
for ($i = 0; $i < count($actualSessions); $i++) {
$elements = $actualSessions[$i]->findElements(WebDriverBy::xpath('.//td'));
$actualSession = array();
foreach ($elements as $e) {
$actualSession[] = $e->getText();
}
$this->assertEquals($expectedSessions[$i], $actualSession, "Sessions at row {$i} differ");
}
}
示例6: testSearch
public function testSearch()
{
$this->webDriver->get($this->url);
// find search field by its id
$search = $this->webDriver->findElement(WebDriverBy::xpath('html/body/div[1]/div[1]/div/div[2]/form/label'));
$search->click();
// typing into field
$this->webDriver->getKeyboard()->sendKeys('php-webdriver');
// pressing "Enter"
$this->webDriver->getKeyboard()->pressKey(WebDriverKeys::ENTER);
$firstResult = $this->webDriver->findElement(WebDriverBy::cssSelector('li.repo-list-item:nth-child(1) > h3:nth-child(2) > a:nth-child(1)'));
$firstResult->click();
// we expect that facebook/php-webdriver was the first result
$this->assertContains("php-webdriver", $this->webDriver->getTitle());
$this->assertEquals('https://github.com/facebook/php-webdriver', $this->webDriver->getCurrentURL());
$this->assertElementNotFound(WebDriverBy::className('avatar'));
}
示例7: enable_compression_sizes
protected function enable_compression_sizes($sizes)
{
self::$driver->get(wordpress('/wp-admin/options-media.php'));
$elements = self::$driver->findElements(WebDriverBy::xpath('//input[starts-with(@id, "tinypng_sizes_")]'));
foreach ($elements as $element) {
$size = str_replace('tinypng_sizes_', '', $element->getAttribute('id'));
if (in_array($size, $sizes)) {
if (!$element->getAttribute('checked')) {
$element->click();
}
} else {
if ($element->getAttribute('checked')) {
$element->click();
}
}
}
self::$driver->findElement(WebDriverBy::tagName('form'))->submit();
}
示例8: testCalendarEntryEditTest
public function testCalendarEntryEditTest()
{
//edit date
$row = self::$webDriver->findElement(WebDriverBy::xpath("//tr[contains(text(), " . "CalendarTestBooking" . ")]/td[8]"));
$row->findElement(WebDriverBy::linkText('Bearbeiten'))->click();
self::$webDriver->findElement(WebDriverBy::id('from[date]_d'))->sendKeys(date('d') + 1);
self::$webDriver->findElement(WebDriverBy::id('from[date]_m'))->sendKeys(date('m'));
self::$webDriver->findElement(WebDriverBy::id('from[date]_y'))->sendKeys(date('Y'));
self::$webDriver->findElement(WebDriverBy::id('from[time]_h'))->sendKeys("14");
self::$webDriver->findElement(WebDriverBy::id('from[time]_m'))->sendKeys("00");
self::$webDriver->findElement(WebDriverBy::id('to[date]_d'))->sendKeys(date('d') + 1);
self::$webDriver->findElement(WebDriverBy::id('to[date]_m'))->sendKeys(date('m'));
self::$webDriver->findElement(WebDriverBy::id('to[date]_y'))->sendKeys(date('Y'));
self::$webDriver->findElement(WebDriverBy::id('to[time]_h'))->sendKeys("15");
self::$webDriver->findElement(WebDriverBy::id('to[time]_m'))->sendKeys("10");
self::$webDriver->findElement(WebDriverBy::name('cmd[saveEditBooking]'))->click();
$this->assertContains("Buchung erfolgreich bearbeitet", self::$helper->getSuccMessage());
self::$webDriver->findElement(WebDriverBy::linkText('Zurück zu den Buchungen'))->click();
// check calendar for booking
self::$webDriver->findElement(WebDriverBy::linkText(self::$helper->getCurrentMonth() . ' ' . date('Y')))->click();
$this->assertContains("14:00 CalendarTestBooking", self::$webDriver->findElement(webDriverBy::cssSelector("div.ilTabContentOuter.ilTabsTableCell"))->getText());
// go back to bookings
self::$webDriver->findElement(WebDriverBy::linkText('Termine'))->click();
}
示例9: match
/**
* @param $page
* @param $selector
* @return array
*/
protected function match($page, $selector)
{
$nodes = array();
if (Locator::isID($selector)) {
$nodes = $page->findElements(\WebDriverBy::id(substr($selector, 1)));
}
if (!empty($nodes)) {
return $nodes;
}
if (Locator::isCSS($selector)) {
$nodes = $page->findElements(\WebDriverBy::cssSelector($selector));
}
if (!empty($nodes)) {
return $nodes;
}
if (Locator::isXPath($selector)) {
$nodes = $page->findElements(\WebDriverBy::xpath($selector));
}
return $nodes;
}
示例10: activate_plugin
function activate_plugin($driver)
{
$driver->get(wordpress('/wp-admin/plugins.php'));
$activate_links = $driver->findElements(WebDriverBy::xpath('//a[starts-with(@href, "plugins.php?action=activate&plugin=tinypng-image-compression")]'));
$deactivate_links = $driver->findElements(WebDriverBy::xpath('//a[starts-with(@href, "plugins.php?action=deactivate&plugin=tinypng-image-compression")]'));
if (count($activate_links) > 0) {
$activate_links[0]->click();
} elseif (count($deactivate_links) > 0) {
print "Plugin already activated.\n";
} else {
var_dump($driver->getPageSource());
throw new UnexpectedValueException('Activating plugin failed.');
}
}
示例11: annualReportCompleteProgramEvaluation
public function annualReportCompleteProgramEvaluation()
{
$prog_eval_cont_imp_link = Automation::grabElementByCssSelector($this->webDriver, '.entity-field-collection-item > div:nth-child(1) > table:nth-child(2) > tbody:nth-child(2) > tr:nth-child(7) > td:nth-child(4) > a:nth-child(1) > span:nth-child(1)');
$prog_eval_cont_imp_link->click();
$first_select_box = $this->webDriver->findElement(WebDriverBy::xpath('//*/select'));
$id = $first_select_box->getAttribute('id');
print $id;
$id_array = explode('-', $id);
$webform_ident = $id_array[3];
Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-{$webform_ident}-meets-standard-1")->click();
$one_year_ago = strtotime('-1 year', time());
$month = date('n', $one_year_ago);
$day = intval(date('d', $one_year_ago));
$year = date('Y', $one_year_ago);
$select = new WebDriverSelect(Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-criterion-{$webform_ident}-last-program-evaluation-month"));
$select->selectByValue($month);
$select = new WebDriverSelect(Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-criterion-{$webform_ident}-last-program-evaluation-day"));
$select->selectByValue($day);
$select = new WebDriverSelect(Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-criterion-{$webform_ident}-last-program-evaluation-year"));
$select->selectByValue($year);
Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-criterion-{$webform_ident}-evidence-forms-surveys-select-1")->click();
$select = new WebDriverSelect(Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-criterion-{$webform_ident}-question-4-when-month"));
$select->selectByValue($month);
$select = new WebDriverSelect(Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-criterion-{$webform_ident}-question-4-when-day"));
$select->selectByValue($day);
$select = new WebDriverSelect(Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-criterion-{$webform_ident}-question-4-when-year"));
$select->selectByValue($year);
Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-{$webform_ident}-criterion-{$webform_ident}-response-criterion-{$webform_ident}-question-4-how-select-1")->click();
Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-10f03-criterion-10f03-response-criterion-10f03-program-meets-standard-1")->click();
Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-10f03-criterion-10f03-response-criterion-10f03-two-program-improvement-goals")->sendKeys('1234');
Automation::grabElementByCssSelector($this->webDriver, "#edit-submitted-criterion-10f03-criterion-10f03-response-criterion-10f03-professional-development-activity")->sendKeys('4321');
Automation::grabElementByCssSelector($this->webDriver, '.webform-submit')->click();
}
示例12: assertMenuIsSelected
/**
* Assert if the given menu is selected.
* @param $text
*/
public function assertMenuIsSelected($text)
{
$elt = $this->driver->findElement(WebDriverBy::xpath("//div[@id = 'js_menu']//a[text()='{$text}']/.."));
$this->assertElementHasClass($elt, 'selected');
}
示例13: findAllByXpath
/**
* Find all elements by a XPath selector
* @param $text
* @return mixed
* @throws NoSuchElementException
*/
public function findAllByXpath($xpath)
{
return $this->driver->findElements(WebDriverBy::xpath($xpath));
}
示例14: 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');
}
示例15: testAssignmentEffectsOfFloorplans
/**
* Tests the effects of changing a floorplan which is assigend to a room
* @test
*/
public function testAssignmentEffectsOfFloorplans()
{
self::$webDriver->findElement(WebDriverBy::linkText('Gebäudeplan'))->click();
self::$helper->createFloorPlan('Test_A', self::$test_file_absolut_path . 'sucess.jpg', 'Test');
//#1 Use a new floorplan by creating a room with it
self::$helper->createRoom('123', '1', '20', "TEST", "Test_A", array());
self::$webDriver->findElement(WebDriverBy::linkText(' Zurück zu allen Räumen '))->click();
self::$webDriver->findElement(WebDriverBy::linkText('123'))->click();
$text = self::$webDriver->findElement(WebDriverBy::xpath("//option[text()='Test_A']"))->getAttribute('selected');
$this->assertEquals(false, empty($text), '#1 Using a new floorplan on a room has failed!');
//#2 Change a floorplan which is assigend to a room
self::$webDriver->findElement(WebDriverBy::linkText('Gebäudeplan'))->click();
$menu = self::$webDriver->findElement(WebDriverBy::xpath("//div[@id='il_center_col']/div[4]/table/tbody/tr[2]/td[4]"));
$menu->findElement(WebDriverBy::linkText('Aktionen'))->click();
$menu->findElement(WebDriverBy::linkText('Bearbeiten'))->click();
self::$webDriver->findElement(WebDriverBy::id('title'))->clear();
self::$webDriver->findElement(WebDriverBy::id('title'))->sendKeys('Test_B');
self::$webDriver->findElement(WebDriverBy::id('file_mode_replace'))->click();
self::$webDriver->findElement(WebDriverBy::id('upload_file'))->sendKeys(self::$test_file_absolut_path . 'sucess.jpg');
self::$webDriver->findElement(WebDriverBy::name('cmd[update]'))->click();
self::$webDriver->findElement(WebDriverBy::linkText('Räume'))->click();
self::$webDriver->findElement(WebDriverBy::linkText('123'))->click();
$text = self::$webDriver->findElement(WebDriverBy::xpath("//option[text()='Test_B']"))->getAttribute('selected');
$this->assertEquals(false, empty($text), '#2 Changing an assigend floorplan has failed!');
//#3 Delete an assigned floorplan
self::$webDriver->findElement(WebDriverBy::linkText('Gebäudeplan'))->click();
self::$helper->deleteAllFloorPlans();
self::$webDriver->findElement(WebDriverBy::linkText('Räume'))->click();
self::$webDriver->findElement(WebDriverBy::linkText('123'))->click();
$text = self::$webDriver->findElement(WebDriverBy::xpath("//option[text()=' - Keine Zuordnung - ']"))->getAttribute('selected');
$this->assertEquals(false, empty($text), '#3 Deleting an assigend floorplan has failed!');
self::$helper->deleteAllRooms();
}