/** * Gets the titles of modules in sliders * * @return array of stdClass objects */ public function getModuleTitles() { $container = $this->driver->findElement(By::Id('panel-sliders')); $elements = $container->findElements(By::tagName('h3')); $return = array(); foreach ($elements as $element) { $object = new stdClass(); $object->text = $element->getText(); } }
/** * function to get all menu types * * @return array */ public function getMenuItemTypes() { $result = array(); $d = $this->driver; $d->findElement(By::xPath("//a[contains(@onclick, 'option=com_menus&view=menutypes')]"))->click(); $el = $d->waitForElementUntilIsPresent(By::xPath("//iframe[contains(@src, 'option=com_menus&view=menutypes')]")); $el = $d->switchTo()->getFrameByWebElement($el); $groups = $d->findElements(By::className('accordion-group')); foreach ($groups as $group) { $toggle = $group->findElement(By::className('accordion-toggle')); $toggleName = $toggle->getText(); $toggle->click(); $d->waitForElementUntilIsPresent(By::xPath("//div[contains(@class, 'accordion-body in')]/div/ul/li/a")); $menuTypes = $el->findElements(By::xPath("//div[contains(@class, 'accordion-body in')]/div/ul/li/a")); foreach ($menuTypes as $menuType) { $allText = $menuType->getText(); $subTextLength = strlen($menuType->findElement(By::tagName('small'))->getText()); $menuTypeText = substr($allText, 0, strlen($allText) - $subTextLength); $result[] = array('group' => $toggleName, 'type' => $menuTypeText); } } return $result; }
/** * 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; }
/** * Prepare wiki text for an option group * Format is: *'''<label>:''' (<option1>/<option2/..) <tooltip text> */ public function toWikiHelpSelect(stdClass $object) { $optionContainer = $this->driver->findElement(By::xPath("//div[@id='" . $object->id . "_chzn']")); $optionContainer->click(); $optionList = $optionContainer->findElement(By::tagName('ul')); $optionText = $this->getOptionText($optionList); return "*'''" . $object->labelText . ":''' (" . implode('/', $optionText) . "). " . $this->getToolTip($object->tab, $object->id) . "\n"; }
/** * Prepare wiki text for permissions tab * */ public function toWikiHelpPermissions($groupId) { $objects = $this->getPermissionInputFields($groupId); foreach ($objects as $object) { $listElement = str_replace('.', '_', $object->id); $optionContainer = $this->driver->findElement(By::xPath("//div[@id='" . $listElement . "_chzn']")); $optionContainer->findElement(By::tagName('a'))->click(); $optionList = $optionContainer->findElement(By::tagName('ul')); $optionText = $this->getOptionText($optionList); $toolTip = $object->element->getAttribute('title') . ". " . $object->tipText; $helpText[] = "*'''" . $object->labelText . ":''' (" . implode('/', $optionText) . "). " . $toolTip . "\n"; $optionContainer->findElement(By::tagName('a'))->click(); } return $helpText; }
public function testFindElements() { $this->_driver->get($this->_url); $webElements = $this->_driver->findElements(By::tagName("input")); foreach ($webElements as $webElement) { $this->assertTrue($webElement instanceof WebElement); } $this->assertTrue(is_array($webElements)); $this->assertTrue(count($webElements) > 0); }
public function getRowText($name) { $result = false; $rowElements = $this->driver->findElement(By::xPath("//tbody"))->findElements(By::tagName('tr')); $count = count($rowElements); for ($i = 0; $i < $count; $i++) { $rowText = $rowElements[$i]->getText(); if (strpos($rowText, $name) !== false) { $result = $rowText; break; } } return $result; }
public function testFindElementsShouldGetOneOfFoundElementsText() { $selectBox = $this->_driver->findElement(By::id("sel1")); $selectBoxOptions = $selectBox->findElements(By::tagName("option")); foreach ($selectBoxOptions as $selectBoxOption) { $this->assertTrue($selectBoxOption instanceof WebElement); if ($selectBoxOption->getAttribute("value") == "4") { $selectBoxOption->click(); } } foreach ($selectBoxOptions as $selectBoxOption) { if ($selectBoxOption->getAttribute("selected") == "true") { $this->assertEquals("Black", $selectBoxOption->getText()); } } }