當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SeleniumClient\By類代碼示例

本文整理匯總了PHP中SeleniumClient\By的典型用法代碼示例。如果您正苦於以下問題:PHP By類的具體用法?PHP By怎麽用?PHP By使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了By類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例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: 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

示例4: setUp

 /**
  * Login to back end and navigate to menu Language Manager.
  *
  * @since   3.0
  */
 public function setUp()
 {
     parent::setUp();
     $cpPage = $this->doAdminLogin();
     $this->tagManagerPage = $cpPage->clickMenu('Language Manager', 'LanguageManagerPage');
     $this->driver->findElement(By::xPath("//ul/li/a[@href='index.php?option=com_languages&view=languages']"))->click();
 }
開發者ID:shoffmann52,項目名稱:install-from-web-server,代碼行數:12,代碼來源:LanguageManager0002Test.php

示例5: SiteLoginUser

 /**
  * Function to enter Username Password
  * 
  * @param string   $username	Username of the user
  * @param string   $password	Password of the user    
  * @return  void
  *
  */
 public function SiteLoginUser($username, $password)
 {
     $d = $this->driver;
     $d->findElement(By::xPath("//input[@id='username']"))->sendKeys($username);
     $d->findElement(By::xPath("//input[@id='password']"))->sendKeys($password);
     $d->findElement(By::xPath("//button[contains(text(), 'Log in')]"))->click();
 }
開發者ID:sural98,項目名稱:joomla-cms,代碼行數:15,代碼來源:SiteLoginPage.php

示例6: 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

示例7: 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

示例8: 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

示例9: deleteLevel

 public function deleteLevel($name)
 {
     $this->searchFor($name);
     $this->driver->findElement(By::name("checkall-toggle"))->click();
     $this->clickButton('toolbar-delete');
     $this->driver->waitForElementUntilIsPresent(By::xPath($this->waitForXpath));
     $this->searchFor();
 }
開發者ID:rasiodesign,項目名稱:joomla-cms,代碼行數:8,代碼來源:LevelManagerPage.php

示例10: 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

示例11: isEditPresent

 /**
  * Function which checks of edit icon is ppresent on the page or not
  *
  * @return True or Flase
  */
 public function isEditPresent()
 {
     $arrayElement = $this->driver->findElements(By::xPath("//a[contains(text(), 'Edit')]"));
     if (count($arrayElement > 0)) {
         return true;
     } else {
         return false;
     }
 }
開發者ID:SysBind,項目名稱:joomla-cms,代碼行數:14,代碼來源:SiteSingleArticlePage.php

示例12: getTabIds

 public function getTabIds()
 {
     $tabs = $this->driver->findElements(By::xPath("//div[@class='tab-content'][@id='myTabContent']/div"));
     $return = array();
     foreach ($tabs as $tab) {
         $return[] = $tab->getAttribute('id');
     }
     return $return;
 }
開發者ID:sural98,項目名稱:joomla-cms,代碼行數:9,代碼來源:ModuleEditPage.php

示例13: getModuleType

 protected function getModuleType()
 {
     $elements = $this->driver->findElements(By::xPath("//span[@class = 'label']"));
     if (count($elements >= 2)) {
         return $elements[1]->getText();
     } else {
         return false;
     }
 }
開發者ID:karimzg,項目名稱:joomla,代碼行數:9,代碼來源:ModuleEditPage.php

示例14: getArticleTitles

 /**
  * Function which returns Title array of Articles on the Home page of Front End
  *
  *
  * @return  Array of Article Titles Visible
  */
 public function getArticleTitles()
 {
     $arrayElement = $this->driver->findElements(By::xPath("//h2//a[contains(text(), '')]"));
     $arrayTitles = array();
     for ($i = 0; $i < count($arrayElement); $i++) {
         $arrayTitles[$i] = $arrayElement[$i]->getText();
     }
     return $arrayTitles;
 }
開發者ID:sural98,項目名稱:joomla-cms,代碼行數:15,代碼來源:SiteArchivedArticlesPage.php

示例15: clearInstallMessages

 /**
  * Clears post-installation messages by navigating to that screen and back
  *
  * @return  null
  */
 public function clearInstallMessages()
 {
     $clearButtons = $this->driver->findElements(By::xPath("//a[contains(text(), 'Hide this message')]"));
     while (count($clearButtons) > 0) {
         $clearButtons[0]->click();
         $page = $this->test->getPageObject('PostinstallPage');
         $clearButtons = $this->driver->findElements(By::xPath("//a[contains(text(), 'Hide this message')]"));
     }
 }
開發者ID:shoffmann52,項目名稱:install-from-web-server,代碼行數:14,代碼來源:PostinstallPage.php


注:本文中的SeleniumClient\By類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。