@Override public WebElement findElement(SearchContext context) { if (context instanceof FindsById) { return ((FindsById) context).findElementById(id); } return ((FindsByXPath) context).findElementByXPath(".//*[@id = '" + id + "']"); }
@Override public WebElement findElement(SearchContext context) { if (context instanceof FindsByName) { return ((FindsByName) context).findElementByName(name); } return ((FindsByXPath) context).findElementByXPath(".//*[@name = '" + name + "']"); }
@Override public WebElement findElement(SearchContext context) { if (context instanceof FindsByTagName) { return ((FindsByTagName) context).findElementByTagName(tagName); } return ((FindsByXPath) context).findElementByXPath(".//" + tagName); }
@Override public List<WebElement> findElements(SearchContext context) { if (context instanceof FindsById) { return ((FindsById) context).findElementsById(id); } return ((FindsByXPath) context).findElementsByXPath(".//*[@id = '" + id + "']"); }
@Override public List<WebElement> findElements(SearchContext context) { if (context instanceof FindsByName) { return ((FindsByName) context).findElementsByName(name); } return ((FindsByXPath) context).findElementsByXPath(".//*[@name = '" + name + "']"); }
@Override public List<WebElement> findElements(SearchContext context) { if (context instanceof FindsByTagName) { return ((FindsByTagName) context).findElementsByTagName(tagName); } return ((FindsByXPath) context).findElementsByXPath(".//" + tagName); }
@Override public WebElement findElement(SearchContext context) { if (context instanceof FindsByClassName) return ((FindsByClassName) context).findElementByClassName(className); return ((FindsByXPath) context).findElementByXPath(".//*[" + "@class = '" + className + "']"); }
public EditPage editItem(int itemId, String domainName) { final WebElement row = getRowForItem(itemId); ((Locatable) row).getCoordinates().inViewPort(); row.findElement(By.xpath(".//a[@title='Edit']")).click(); return new EditPage(seleniumContext, domainName, itemId).get(); }
private void setUpElementFindingStrategies() { lookupStrategies.put("alt", new AltLookupStrategy()); lookupStrategies.put("class", new ClassLookupStrategy()); lookupStrategies.put("id", new IdLookupStrategy()); lookupStrategies.put("identifier", new IdentifierLookupStrategy()); lookupStrategies.put("implicit", new ImplicitLookupStrategy()); lookupStrategies.put("link", new LinkLookupStrategy()); lookupStrategies.put("name", new NameLookupStrategy()); lookupStrategies.put("xpath", new XPathLookupStrategy()); lookupStrategies.put("dom", new DomTraversalLookupStrategy()); }
public WebElement find(WebDriver driver, String use) { try { return new IdLookupStrategy().find(driver, use); } catch (NoSuchElementException e) { return new NameLookupStrategy().find(driver, use); } } }
private void setUpOptionFindingStrategies() { optionSelectStrategies.put("implicit", new LabelOptionSelectStrategy()); optionSelectStrategies.put("id", new IdOptionSelectStrategy()); optionSelectStrategies.put("index", new IndexOptionSelectStrategy()); optionSelectStrategies.put("label", new LabelOptionSelectStrategy()); optionSelectStrategies.put("value", new ValueOptionSelectStrategy()); }
public static void copyResource(File outputDir, Class forClassLoader, String... names) throws IOException { for (String name : names) { InputStream is = locateResource(forClassLoader, name); try { unzipFile(outputDir, is, name); } finally { Cleanly.close(is); } } }
@Override public List<WebElement> findElements(SearchContext context) { if (context instanceof FindsById) return ((FindsById) context).findElementsById(id); return ((FindsByXPath) context).findElementsByXPath("*[@id = '" + id + "']"); }
@Override public List<WebElement> findElements(SearchContext context) { if (context instanceof FindsByName) return ((FindsByName) context).findElementsByName(name); return ((FindsByXPath) context).findElementsByXPath(".//*[@name = '" + name + "']"); }
@Override public WebElement findElement(SearchContext context) { if (context instanceof FindsById) return ((FindsById) context).findElementById(id); return ((FindsByXPath) context).findElementByXPath("*[@id = '" + id + "']"); }
@Override public List<WebElement> findElements(SearchContext context) { if (context instanceof FindsByTagName) return ((FindsByTagName) context).findElementsByTagName(name); return ((FindsByXPath) context).findElementsByXPath(".//" + name); }
@Override public WebElement findElement(SearchContext context) { if (context instanceof FindsByTagName) return ((FindsByTagName) context).findElementByTagName(name); return ((FindsByXPath) context).findElementByXPath(".//" + name); }
public ShowViewPage submit() { webDriver().scrollTo(500); ((Locatable) saveButton).getCoordinates().inViewPort(); saveButton.click(); return new ShowViewPage( seleniumContext, domainName, getItemId() ).get(); }
@Override public void select( String... optionNames ) { expandOptionList(); webDriver().waitForElementVisible( valueList ); final WebElement optionToSelect = valueList.findElement( By.xpath( String.format( "//li[contains(text(),'%s')]", optionNames[ 0 ] ) ) ); ( ( Locatable ) optionToSelect ).getCoordinates().inViewPort(); optionToSelect.click(); webDriver().waitForElementVisible( getSelectedOption( optionNames[ 0 ] ) ); }
private void addSelection( String option ) { optionList = theField.findElement(By.className("chzn-drop")); expandOptionList(); final WebElement optionToSelect = findOptionByText(optionList, option); assert optionToSelect != null; ( ( Locatable ) optionToSelect ).getCoordinates().inViewPort(); optionToSelect.click(); webDriver().waitForElementVisible( getSelectedOption( option ) ); }