本文整理汇总了Java中org.openqa.selenium.By.ByCssSelector类的典型用法代码示例。如果您正苦于以下问题:Java ByCssSelector类的具体用法?Java ByCssSelector怎么用?Java ByCssSelector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ByCssSelector类属于org.openqa.selenium.By包,在下文中一共展示了ByCssSelector类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testData
import org.openqa.selenium.By.ByCssSelector; //导入依赖的package包/类
@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();
}
示例2: shouldRegisterWhenFlattenedLocatorFileIsLoaded
import org.openqa.selenium.By.ByCssSelector; //导入依赖的package包/类
@Test
public void shouldRegisterWhenFlattenedLocatorFileIsLoaded() throws URISyntaxException {
File locatorFile = new File(LocatorRegistryTest.class.getResource("/conf/flattened/locator.yml").toURI());
LocatorRegistry locatorRegistry = new LocatorRegistry(new Properties(), locatorFile);
assertTrue(locatorRegistry.getLocator("my-button") instanceof ByCssSelector);
assertTrue(locatorRegistry.getLocator("my-input") instanceof ByXPath);
assertTrue(locatorRegistry.getLocator("my-frame") instanceof ById);
assertEquals(new ByCssSelector("#mypage .mybutton"), locatorRegistry.getLocator("my-button"));
assertEquals(new ByXPath("//input[@class='myinput']"), locatorRegistry.getLocator("my-input"));
assertEquals(new ById("myframe"), locatorRegistry.getLocator("my-frame"));
}
示例3: shouldRegisterDefaultProfileWhenLocatorPropertyIsNotSet
import org.openqa.selenium.By.ByCssSelector; //导入依赖的package包/类
@Test
public void shouldRegisterDefaultProfileWhenLocatorPropertyIsNotSet() throws URISyntaxException {
File locatorFile = new File(LocatorRegistryTest.class.getResource("/conf/hierarchical/locator.yml").toURI());
LocatorRegistry locatorRegistry = new LocatorRegistry(new Properties(), locatorFile);
assertTrue(locatorRegistry.getLocator("my-button") instanceof ByCssSelector);
assertTrue(locatorRegistry.getLocator("my-input") instanceof ByXPath);
assertTrue(locatorRegistry.getLocator("my-frame") instanceof ById);
assertEquals(new ByCssSelector("#mypage .mybutton"), locatorRegistry.getLocator("my-button"));
assertEquals(new ByXPath("//input[@class='myinput']"), locatorRegistry.getLocator("my-input"));
assertEquals(new ById("myframe"), locatorRegistry.getLocator("my-frame"));
}
示例4: shouldRegisterUserSpecifiedProfileWhenLocatorPropertyIsSet
import org.openqa.selenium.By.ByCssSelector; //导入依赖的package包/类
@Test
public void shouldRegisterUserSpecifiedProfileWhenLocatorPropertyIsSet() throws URISyntaxException {
Properties properties = new Properties();
properties.setProperty("locator", "override");
File locatorFile = new File(LocatorRegistryTest.class.getResource("/conf/hierarchical/locator.yml").toURI());
LocatorRegistry locatorRegistry = new LocatorRegistry(properties, locatorFile);
assertTrue(locatorRegistry.getLocator("my-button") instanceof ByCssSelector);
assertTrue(locatorRegistry.getLocator("my-input") instanceof ByXPath);
assertTrue(locatorRegistry.getLocator("my-frame") instanceof ById);
assertEquals(new ByCssSelector("#overridepage .overridebutton"), locatorRegistry.getLocator("my-button"));
assertEquals(new ByXPath("//input[@class='myinput']"), locatorRegistry.getLocator("my-input"));
assertEquals(new ById("myframe"), locatorRegistry.getLocator("my-frame"));
}
示例5: testLocator
import org.openqa.selenium.By.ByCssSelector; //导入依赖的package包/类
@Test
public void testLocator() {
getBundle().setProperty("test.loc",
"{'locator':'css=a','desc':' Trip type check box'}");
assertThat(LocatorUtil.getBy("test.loc"), instanceOf(ByCssSelector.class));
}