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


PHP By::id方法代码示例

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


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

示例1: testDemo1

 public function testDemo1()
 {
     //get url
     $this->_driver->get($this->_testUrl);
     //access text input
     $webElement = $this->_driver->findElement(By::id("txt1"));
     $webElement->clear();
     $webElement->sendKeys("Text sent 1");
     $this->assertEquals("Text sent 1", $webElement->getAttribute("value"));
     $webElement = $this->_driver->findElement(By::id("txt2"));
     $webElement->clear();
     $webElement->sendKeys("Text sent 2");
     $this->assertEquals("Text sent 2", $webElement->getAttribute("value"));
     //access listbox
     $selectElement = new SelectElement($this->_driver->findElement(By::id("sel1")));
     $selectElement->selectByValue("4");
     $this->assertTrue($selectElement->getElement()->findElement(By::xPath(".//option[@value = 4]"))->isSelected());
     //access checkbox
     $webElement = $this->_driver->findElement(By::cssSelector("html body table tbody tr td fieldset form p input#chk3"));
     $webElement->click();
     $this->assertTrue($webElement->isSelected());
     //access radio
     $webElement = $this->_driver->findElement(By::id("rd3"));
     $webElement->click();
     $this->assertTrue($webElement->isSelected());
     //access button
     $webElement = $this->_driver->findElement(By::id("btnSubmit"));
     $webElement->click();
     //access h2
     $webElement = $this->_driver->findElement(By::cssSelector("html body h2#h2FormReceptor"));
     $this->assertEquals("Form receptor", $webElement->getText());
     sleep(20);
 }
开发者ID:ron-inbar,项目名称:PHP-SeleniumClient,代码行数:33,代码来源:Demo1.php

示例2: testTinyTyping

 public function testTinyTyping()
 {
     $d = $this->_driver;
     //get url
     $d->get($this->_testUrl . '/administrator');
     //access text input
     $webElement = $d->findElement(By::id("mod-login-username"));
     $webElement->clear();
     $webElement->sendKeys("admin");
     $webElement = $d->findElement(By::id("mod-login-password"));
     $webElement->clear();
     $webElement->sendKeys("password");
     //access button
     $d->findElement(By::partialLinkText("Log in"))->click();
     $d->waitForElementUntilIsPresent(By::partialLinkText('Add New Article'))->click();
     $salt = mt_rand();
     $d->waitForElementUntilIsPresent(By::id('jform_title'))->sendKeys('Article Title ' . $salt);
     $d->switchTo()->getFrameByName('jform_articletext_ifr');
     $d->findElement(By::id('tinymce'))->sendKeys('This is some article text.');
     $d->switchTo()->getDefaultFrame();
     $d->findElement(By::xPath("//a[contains(@onclick, 'article.save')]"))->click();
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('Article Title ' . $salt));
     $this->assertInstanceOf('SeleniumClient\\WebElement', $el);
     $el->click();
     $d->waitForElementUntilIsPresent(By::id('jform_title'));
     $select = new SelectElement($d->findElement(By::id("jform_state")));
     $select->selectByValue("2");
     $select = new SelectElement($d->findElement(By::id("jform_featured")));
     $select->selectByValue("1");
     sleep(5);
     // Clean up
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:32,代码来源:Test3.php

示例3: createMenuItem

 /**
  * @test
  */
 public function createMenuItem()
 {
     $cpPage = $this->doAdminLogin();
     $page = $cpPage->clickMenu('Main Menu');
     $page->clickButton('New');
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('New'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[contains(@onclick, 'iframe')]"));
     echo "found select button";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     // switch to modal iframe
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Single Article'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[@value='Single Article']"));
     $salt = mt_rand();
     $d->findElement(By::id('jform_title'))->sendKeys('Test Menu Title ' . $salt);
     $el = $d->findElement(By::partialLinkText('Select / Change'))->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Australian Parks'));
     $el->click();
     $el = $d->waitForElementUntilIsNotPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $d->findElement(By::xPath("//a[contains(@onclick, 'item.save')]"))->click();
     // Clean up
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:28,代码来源:Test1.php

示例4: testUntilShouldWaitShouldThrowException

 public function testUntilShouldWaitShouldThrowException()
 {
     $this->setExpectedException('SeleniumClient\\WebDriverWaitTimeoutException');
     $this->_driver->findElement(By::id("btnAppendDiv"))->click();
     $wait = new WebDriverWait(3);
     $label = $wait->until($this->_driver, "findElement", array(By::id("dDiv1-0"), true));
 }
开发者ID:ron-inbar,项目名称:PHP-SeleniumClient,代码行数:7,代码来源:WebDriverWaitTest.php

示例5: testCreateMenuItem

 public function testCreateMenuItem()
 {
     $d = $this->driver;
     $cpPage = $this->doAdminLogin();
     // 		$genericPage = new GenericAdminPage($d, $this);
     $genericPage = $cpPage->clickMenu('Menu Manager');
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('Main Menu'));
     echo "found Main Menu";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('New'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[contains(@onclick, 'iframe')]"));
     echo "found select button";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     // switch to modal iframe
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Single Article'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[@value='Single Article']"));
     $salt = mt_rand();
     $d->findElement(By::id('jform_title'))->sendKeys('Test Menu Title ' . $salt);
     $el = $d->findElement(By::partialLinkText('Select / Change'))->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Australian Parks'));
     $text = $d->findElement(By::xPath("//body"))->getText();
     $this->assertTrue(strpos($text, '( ! ) Notice:') === false, '**PHP notice found on page.');
     $el->click();
     $el = $d->waitForElementUntilIsNotPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $d->findElement(By::xPath("//a[contains(@onclick, 'item.save')]"))->click();
     // Clean up
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:31,代码来源:Test4.php

示例6: testDemo2

 public function testDemo2()
 {
     //click button/get alert text
     $this->_driver->get($this->_testUrl);
     $this->_driver->findElement(By::id("btnAlert"))->click();
     $this->assertEquals("Here is the alert", $this->_driver->getAlertText());
     $this->_driver->acceptAlert();
     //get main window handle
     $mainWindowHandle = $this->_driver->getCurrentWindowHandle();
     //open popup window / handle its elements
     $this->_driver->findElement(By::id("btnPopUp1"))->click();
     $this->_driver->switchTo()->getWindow("popup1");
     $webElement = $this->_driver->waitForElementUntilIsPresent(By::id("txt1"));
     $webElement->sendKeys("test window");
     $this->assertEquals("test window", $webElement->getAttribute("value"));
     $this->_driver->closeCurrentWindow();
     $this->_driver->switchTo()->getWindow($mainWindowHandle);
     //get iframe / handle its elements
     $this->_driver->getFrame("iframe1");
     $webElement = $this->_driver->waitForElementUntilIsPresent(By::id("txt1"));
     $webElement->sendKeys("test iframe");
     $this->assertEquals("test iframe", $webElement->getAttribute("value"));
     $this->_driver->switchTo()->getWindow($mainWindowHandle);
     //wait for element to be present
     $this->_driver->findElement(By::id("btnAppendDiv"))->click();
     $wait = new WebDriverWait(8);
     $label = $wait->until($this->_driver, "findElement", array(By::id("dDiv1-0"), true));
     $this->assertEquals("Some content", $label->getText());
     sleep(5);
 }
开发者ID:ron-inbar,项目名称:PHP-SeleniumClient,代码行数:30,代码来源:Demo2.php

示例7: testGetAlertShouldSendKeysToAlert

 public function testGetAlertShouldSendKeysToAlert()
 {
     $this->_driver->get($this->_url);
     $this->_driver->findElement(By::id("btnPrompt"))->click();
     $this->_alert->sendKeys("alert text");
     $this->_alert->accept();
     $alertText = $this->_alert->getText();
     $this->assertEquals("alert text", $alertText);
 }
开发者ID:ron-inbar,项目名称:PHP-SeleniumClient,代码行数:9,代码来源:AlertTest.php

示例8: testSelectByPartialTextShouldSelect

 public function testSelectByPartialTextShouldSelect()
 {
     $this->_driver->get($this->_url);
     $select = new SelectElement($this->_driver->findElement(By::id("sel1")));
     $select->selectByPartialText("Red");
     $this->assertTrue($select->getElement()->findElement(By::xPath("option[@value = 2]"))->isSelected());
     $select = new SelectElement($this->_driver->findElement(By::id("sel2")));
     $select->selectByPartialText("peppers");
     $this->assertTrue($select->getElement()->findElement(By::xPath("option[@value = 'greenpeppers']"))->isSelected());
 }
开发者ID:ron-inbar,项目名称:PHP-SeleniumClient,代码行数:10,代码来源:SelectElementTest.php

示例9: getFieldValue

 public function getFieldValue($label)
 {
     $result = false;
     if ($label == 'ID') {
         $result = $this->driver->findElement(By::id('jform_user_id'))->getAttribute('value');
     } else {
         $result = parent::getFieldValue($label);
     }
     return $result;
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:10,代码来源:UserNotesEditPage.php

示例10: executeLogin

 private function executeLogin($userName, $password)
 {
     $webElement = $this->driver->findElement(By::id("mod-login-username"));
     $webElement->clear();
     $webElement->sendKeys($this->cfg->username);
     $webElement = $this->driver->findElement(By::id("mod-login-password"));
     $webElement->clear();
     $webElement->sendKeys($this->cfg->password);
     //access button
     $this->driver->findElement(By::xPath("//button[contains(., 'Log in')]"))->click();
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:11,代码来源:AdminLoginPage.php

示例11: getModuleTypes

 /**
  * Gets all module types available
  *
  * @return  array  associative array of 'site' or 'administrator' => module name
  */
 public function getModuleTypes()
 {
     $result = array();
     $clients = array('Site', 'Administrator');
     foreach ($clients as $client) {
         $this->setFilter('filter_client_id', $client);
         $this->clickButton('toolbar-new');
         $this->driver->waitForElementUntilIsPresent(By::xPath("//h2[contains(., 'Select a Module Type')]"));
         $el = $this->driver->findElement(By::id('new-modules-list'));
         $moduleElements = $el->findElements(By::xPath("//a/strong"));
         foreach ($moduleElements as $element) {
             $result[] = array('client' => strtolower($client), 'name' => $element->getText());
         }
         $this->driver->findElement(By::xPath("//button[contains(., 'Cancel')]"))->click();
         $moduleManagerPage = $this->test->getPageObject('ModuleManagerPage');
     }
     return $result;
 }
开发者ID:sural98,项目名称:joomla-cms,代码行数:23,代码来源:ModuleManagerPage.php

示例12: testCreateMenuItem

 public function testCreateMenuItem()
 {
     //get url
     $this->_driver->get($this->_testUrl . '/administrator');
     //access text input
     $webElement = $this->_driver->findElement(By::id("mod-login-username"));
     $webElement->clear();
     $webElement->sendKeys("admin");
     $webElement = $this->_driver->findElement(By::id("mod-login-password"));
     $webElement->clear();
     $webElement->sendKeys("password");
     //access button
     $this->_driver->findElement(By::partialLinkText("Log in"))->click();
     $d = $this->_driver;
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('Menu Manager'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('Main Menu'));
     echo "found Main Menu";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::partialLinkText('New'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[contains(@onclick, 'iframe')]"));
     echo "found select button";
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     // switch to modal iframe
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Single Article'));
     $el->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//input[@value='Single Article']"));
     $salt = mt_rand();
     $d->findElement(By::id('jform_title'))->sendKeys('Test Menu Title ' . $salt);
     $el = $d->findElement(By::partialLinkText('Select / Change'))->click();
     $el = $d->waitForElementUntilIsPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $el = $d->switchTo()->getFrameByWebElement($el)->findElement(By::partialLinkText('Australian Parks'));
     $el->click();
     $el = $d->waitForElementUntilIsNotPresent(By::xPath("//div[@id='sbox-content']/iframe"));
     $d->findElement(By::xPath("//a[contains(@onclick, 'item.save')]"))->click();
     // Clean up
 }
开发者ID:rasiodesign,项目名称:joomla-cms,代码行数:39,代码来源:Test1.php

示例13: searchFor

 public function searchFor($search = false)
 {
     if ($search) {
         $el = $this->driver->findElement(By::id('filter_search'));
         $el->clear();
         $el->sendKeys($search);
         $this->driver->findElement(By::xPath("//button[@data-original-title='Search' or @title='Search']"))->click();
     } else {
         $this->driver->findElement(By::xPath("//div[@id='filter-bar']//button[@title='Clear' or @title='Reset' or @data-original-title='Reset']"))->click();
     }
     return $this->test->getPageObject(get_class($this));
 }
开发者ID:rasiodesign,项目名称:joomla-cms,代码行数:12,代码来源:AdminManagerPage.php

示例14: getVisibleMenuLinks

 /**
  * Gets array of visible links in the menu container
  * This is normally the header menu for back-end manager screens
  *
  * @return  array of stdClass objects
  */
 public function getVisibleMenuLinks()
 {
     $menuContainer = $this->driver->findElement(By::id('menu'));
     $menus = $menuContainer->findElements(By::tagName('a'));
     $return = array();
     foreach ($menus as $menu) {
         if ($text = $menu->getText()) {
             $menuObject = new stdClass();
             $menuObject->text = $text;
             $menuObject->href = $menu->getAttribute('href');
             $menuObject->id = $menu->getElementId();
             $return[] = $menuObject;
         }
     }
     return $return;
 }
开发者ID:rasiodesign,项目名称:joomla-cms,代码行数:22,代码来源:AdminPage.php

示例15: setRequestVariable

 /**
  * function to set request variable
  *
  * @param   string   $value stores  value
  *
  * @return void
  */
 public function setRequestVariable($value)
 {
     $this->selectTab('Details');
     $d = $this->driver;
     $d->findElement(By::xPath("//a[contains(@class, 'modal btn')][contains(@rel, 'iframe')]"))->click();
     $frameElement = $d->waitForElementUntilIsPresent(By::xPath("//iframe[contains(@src, 'layout=modal')]"));
     $d->switchTo()->getFrameByWebElement($frameElement);
     $filter = $d->waitForElementUntilIsPresent(By::id('filter_search'));
     $filter->clear();
     $filter->sendKeys($value);
     $d->findElement(By::xPath("//button[@data-original-title = 'Search']"))->click();
     $d->waitForElementUntilIsPresent(By::xPath("//button[@data-original-title = 'Search']"));
     $d->findElement(By::xPath("//a[contains(text(), '" . $value . "')]"))->click();
     $d->waitForElementUntilIsNotPresent(By::xPath("//iframe[contains(@src, 'layout=modal')]"));
     $d->switchTo()->getDefaultFrame();
 }
开发者ID:klas,项目名称:joomla-cms,代码行数:23,代码来源:MenuItemEditPage.php


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