org.openqa.selenium.By.ByName Java Examples
The following examples show how to use
org.openqa.selenium.By.ByName.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElementFactory.java From aquality-selenium-java with Apache License 2.0 | 5 votes |
private static Map<Class<? extends By>, String> getLocatorToXPathTemplateMap() { Map<Class<? extends By>, String> locatorToXPathTemplateMap = new HashMap<>(); locatorToXPathTemplateMap.put(ByClassName.class, "//*[contains(@class,'%s')]"); locatorToXPathTemplateMap.put(ByName.class, "//*[@name='%s']"); locatorToXPathTemplateMap.put(ById.class, "//*[@id='%s']"); locatorToXPathTemplateMap.put(ByIdOrName.class, "//*[@id='%1$s' or @name='%1$s']"); return locatorToXPathTemplateMap; }
Example #2
Source File: LocatorUtilTest.java From qaf with MIT License | 5 votes |
@DataProvider(name = "locatorDP") public static Iterator<Object[]> testData() { ArrayList<Object[]> data = new ArrayList<Object[]>(); data.add(new Object[]{"id=eleId", ById.class}); data.add(new Object[]{"name=eleName", ByName.class}); data.add(new Object[]{"css=#eleId.className", ByCssSelector.class}); data.add(new Object[]{"tagName=div", ByTagName.class}); data.add(new Object[]{"link=Link Text", ByLinkText.class}); data.add(new Object[]{"partialLink=Link Text", ByPartialLinkText.class}); data.add(new Object[]{"['css=#qa','name=eleName']", ByAny.class}); // self descriptive data.add(new Object[]{"{'locator' : 'id=eleId'; 'desc' : 'locate element by id'}", ById.class}); data.add(new Object[]{ "{'locator' : 'name=eleName'; 'desc' : 'locate element by name'}", ByName.class}); data.add(new Object[]{ "{'locator' : 'css=#eleId.className'; 'desc' : 'locate element by css'}", ByCssSelector.class}); data.add(new Object[]{ "{'locator' : ['css=#qa','name=eleName']; 'desc' : 'locate element by css'}", ByAny.class}); data.add(new Object[]{"xpath=//*[text()='Albany-Rensselaer, NY (ALB)']", ByXPath.class}); return data.iterator(); }