Java 类org.openqa.selenium.support.ByIdOrName 实例源码
项目:selenide-appium
文件:SelenideAppiumFieldDecorator.java
@Override
public Object decorate(ClassLoader loader, Field field) {
By selector = new Annotations(field).buildBy();
if (selector instanceof ByIdOrName) {
// throw new IllegalArgumentException("Please define locator for " + field);
return decorateWithAppium(loader, field);
} else if (WebElement.class.isAssignableFrom(field.getType())) {
return ElementFinder.wrap(searchContext, selector, 0);
} else if (ElementsCollection.class.isAssignableFrom(field.getType())) {
return new ElementsCollection(new BySelectorCollection(searchContext, selector));
} else if (ElementsContainer.class.isAssignableFrom(field.getType())) {
return createElementsContainer(selector, field);
} else if (isDecoratableList(field, ElementsContainer.class)) {
return createElementsContainerList(field);
} else if (isDecoratableList(field, SelenideElement.class)) {
return SelenideElementListProxy.wrap(factory.createLocator(field));
}
return decorateWithAppium(loader, field);
}
项目:SimpleSe
文件:StrategyTest.java
@DataProvider
public Object[][] getTestData(Method method) {
if (method.getName().equals("testStrategyHappyFlows")) {
return new Object[][] {
{"//h1", By.ByXPath.class},
{"/h1", By.ByXPath.class},
{"./h1", By.ByXPath.class},
{"css=", By.ByCssSelector.class},
{"foo", ByIdOrName.class}
};
}
return new Object[][] {
{""},
{null}
};
}
项目:SimpleSe
文件:JsonWebElementTest.java
@DataProvider
public Object[][] getTestData() {
return new Object[][] {
//basic object creation test data
{newJson(), "en_US", "en_US", Until.Available, JsonWebElement.DEFAULT_WAIT_TIME, By.ByXPath.class},
//checking if different xpath combinations yield proper results.
{newJson("foo", "en_US", "//h1"), "en_US", "fr_FR", Until.Available, JsonWebElement.DEFAULT_WAIT_TIME, By.ByXPath.class},
{newJson("foo", "en_US", "/h1"), "en_US", "fr_FR", Until.Available, JsonWebElement.DEFAULT_WAIT_TIME, By.ByXPath.class},
{newJson("foo", "en_US", "./h1"), "en_US", "fr_FR", Until.Available, JsonWebElement.DEFAULT_WAIT_TIME, By.ByXPath.class},
//checking if css is parsed properly.
{newJson("foo", "en_US", "css=foo"), "en_US", "fr_FR", Until.Available, JsonWebElement.DEFAULT_WAIT_TIME, By.ByCssSelector.class},
//checking if byId/byName is parsed properly.
{newJson("foo", "en_US", "foo"), "en_US", "fr_FR", Until.Available, JsonWebElement.DEFAULT_WAIT_TIME, ByIdOrName.class},
//checking if Until defaults to Available when its empty (or) missing
{newJson("", 10), "en_US", "fr_FR", Until.Available, 10, By.ByXPath.class},
{newJsonWithout(JsonWebElement.WaitAttributes.UNTIL, "25"), "en_US", "en_US", Until.Available, 25, By.ByXPath.class},
//checking if other custom values for until are parsed properly.
{newJson(Until.Clickable.name(), 10), "en_US", "fr_FR", Until.Clickable, 10, By.ByXPath.class},
//checking if time defaults to default wait time if its less than zero (or) when its missing
{newJson(Until.Clickable.name(), 0), "en_US", "fr_FR", Until.Clickable, JsonWebElement.DEFAULT_WAIT_TIME, By.ByXPath.class},
{newJsonWithout(JsonWebElement.WaitAttributes.FOR, Until.Visible.name()), "en_US", "en_US", Until.Visible, JsonWebElement.DEFAULT_WAIT_TIME, By.ByXPath.class}
};
}
项目:SimpleSe
文件:JsonWebElementTest.java
@Test
public void testElementRetrievalForRequestedLocaleWhenMultipleLocalesPresent() {
JsonObject object = newJson();
JsonObject localeObject = new JsonObject();
localeObject.addProperty(JsonWebElement.MandatoryKeys.NAME, "en_FR");
localeObject.addProperty(JsonWebElement.MandatoryKeys.LOCATOR, "h2");
object.get(JsonWebElement.MandatoryKeys.LOCALE).getAsJsonArray().add(localeObject);
JsonWebElement element = JsonWebElement.newElement(object, "en_US");
By actual = element.getLocationStrategy("en_FR");
Assert.assertEquals(actual.getClass(), ByIdOrName.class);
}
项目:cinnamon
文件:Annotations.java
protected By buildByFromDefault() {
return new ByIdOrName(field.getName());
}