当前位置: 首页>>代码示例>>Java>>正文


Java PageFactory类代码示例

本文整理汇总了Java中org.openqa.selenium.support.PageFactory的典型用法代码示例。如果您正苦于以下问题:Java PageFactory类的具体用法?Java PageFactory怎么用?Java PageFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PageFactory类属于org.openqa.selenium.support包,在下文中一共展示了PageFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
/**
 * 1. map elements of interest to their name
 * 2. reload elements from the page every time `map` is called  
 * 
 * E.g., Say ELEMENT_LOCATORS=id 
 * 			and <input id="username" type="text"></input>
 * 			then nameElementMap will contain "username" => WebElement
 */
@Override
protected void map(AbstractPage p) {
	getBys();
	List<WebElement> elements = new ArrayList<WebElement>();
	for (By by : bys) {
		elements.addAll(driver.findElements(by));
	}
	PageFactory.initElements(driver, this);
	String[] tokens = locators.split(",");
	for(WebElement w: elements) {
		for (String s : tokens) {
			try{
				String attr = w.getAttribute(s);//throws StaleElementReferenceException
				if (attr != null) {
					nameElementMap.put(attr, w);
				}
			}catch(StaleElementReferenceException se){
				//ignoring elements which have become stale because
				//a stale object shouldn't have to be referenced 
				//by an automation script
			}
		}
	}
}
 
开发者ID:saiscode,项目名称:kheera,代码行数:33,代码来源:PageObject.java

示例2: addPageObject

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
public AbstractPage addPageObject(AbstractPage p) {
	String url = p.forUrl();
	if(!mapper.containsKey(url)){
		mapper.put(url, p);
		String currentUrl = null;
		try{
			String currUrl = driver.getCurrentUrl();
			URI url2 = new URI(currUrl);
			String path = url2.getPath();
			currentUrl = currUrl.substring(0, currUrl.indexOf(path));
		}catch (URISyntaxException e) {
			e.printStackTrace();
		} catch(NullPointerException npe){
			currentUrl = baseUrl;
		}
		p.setBaseUrl(baseUrl.equals(currentUrl) ? baseUrl: currentUrl);
		PageFactory.initElements(driver, p);
	}
	return mapper.get(url);
}
 
开发者ID:saiscode,项目名称:kheera,代码行数:21,代码来源:TestExecutionController.java

示例3: ApplicationPageStructuralFactory

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
public ApplicationPageStructuralFactory(WebDriver driver, TodoMVCSite todoMVCSite) {

        PageFactory.initElements(driver, this);

        this.driver = driver;
        this.todoMVCSite = todoMVCSite;
        wait = new WebDriverWait(driver,10);

        // move the mouse out of the way so it
        // doesn't interfere with the test
        try {
            new Robot().mouseMove(0,0);
        } catch (AWTException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:eviltester,项目名称:automationAbstractions,代码行数:17,代码来源:ApplicationPageStructuralFactory.java

示例4: testAddAndRemoveWordLabel

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@Test
public void testAddAndRemoveWordLabel() {
	AudioListPage audioListPage = PageFactory.initElements(driver, AudioListPage.class);
    if (audioListPage.getListCount() > 0) {
        audioListPage.clickRandomEditLink();

        AudioEditPage audioEditPage = PageFactory.initElements(driver, AudioEditPage.class);
        audioEditPage.addWordLabel("apple");
        
        // Refresh current page
        driver.navigate().refresh();
        
        PageFactory.initElements(driver, AudioEditPage.class);
        audioEditPage.removeWordLabel("apple");
    }
}
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:17,代码来源:AudioEditTest.java

示例5: testEdit

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@Test
    public void testEdit() {
    	VideoListPage videoListPage = PageFactory.initElements(driver, VideoListPage.class);
        if (videoListPage.getListCount() > 0) {
            videoListPage.clickRandomEditLink();

            VideoEditPage videoEditPage = PageFactory.initElements(driver, VideoEditPage.class);
            videoEditPage.submitForm();

            // TODO
//            PageFactory.initElements(driver, VideoListPage.class);
        }
    }
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:14,代码来源:VideoEditTest.java

示例6: RiotSettingsPageObjects

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
public RiotSettingsPageObjects(AppiumDriver<MobileElement> myDriver) throws InterruptedException{
	driver=(AndroidDriver<MobileElement>) myDriver;
	PageFactory.initElements(new AppiumFieldDecorator(myDriver), this);
	try {
		waitUntilDisplayed((AndroidDriver<MobileElement>) driver,"im.vector.alpha:id/vector_settings_page", true, 10);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}
 
开发者ID:vector-im,项目名称:riot-automated-tests,代码行数:10,代码来源:RiotSettingsPageObjects.java

示例7: showDialog

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@BeforeMethod public void showDialog() throws Throwable {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame = new JFrame(JTreeDynamicTreeTest.class.getSimpleName());
            frame.setName("frame-" + JTreeDynamicTreeTest.class.getSimpleName());
            frame.getContentPane().add(new DynamicTreeDemo(), BorderLayout.CENTER);
            frame.pack();
            frame.setAlwaysOnTop(true);
            frame.setVisible(true);
        }
    });
    driver = new JavaDriver();
    page = PageFactory.initElements(driver, DynamicTreePage.class);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:JTreeDynamicTreeTest.java

示例8: initElementsContainer

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
private ElementsContainer initElementsContainer(Class<?> type, SelenideElement self) throws Exception {
  Constructor<?> constructor = type.getDeclaredConstructor();
  constructor.setAccessible(true);
  ElementsContainer result = (ElementsContainer) constructor.newInstance();
  PageFactory.initElements(new SelenideFieldDecorator(self), result);
  result.setSelf(self);
  return result;
}
 
开发者ID:codeborne,项目名称:selenide-appium,代码行数:9,代码来源:SelenideAppiumFieldDecorator.java

示例9: setUp

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();

    loginPO = PageFactory.initElements(getDriver(), LoginPageObject.class);
    loginPO.login("admin", "admin");
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:8,代码来源:AlignmentIT.java

示例10: setUp

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();

    // Use the PageFactory to automatically initialize fields.
    loginPO = PageFactory.initElements(getDriver(), LoginPageObject.class);
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:8,代码来源:NewUserIT.java

示例11: setUp

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@Override
public void setUp() throws Exception {
    super.setUp();

    messages = Messages.getInstance(Locale.getDefault());

    loginPO = PageFactory.initElements(getDriver(), LoginPageObject.class);
    loginPO.login("admin", "admin");
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:10,代码来源:NewCharacterIT.java

示例12: PageBase

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
public PageBase(WebDriver driver) {
	if(driver == null)
		throw new IllegalArgumentException("Driver object is null");
	
	PageFactory.initElements(new AjaxElementLocatorFactory(driver, 10), this);
	this.driver = driver;
}
 
开发者ID:rahulrathore44,项目名称:SeleniumCucumber,代码行数:8,代码来源:PageBase.java

示例13: testInit

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@Parameters({ "path" })
@BeforeClass
public void testInit(String path) {

	// Load the page in the browser
	webDriver.get(websiteUrl + path);
	homepage = PageFactory.initElements(webDriver, HomePage.class);
}
 
开发者ID:ViliamS,项目名称:XPathBuilder,代码行数:9,代码来源:HomePageTest.java

示例14: testListNotEmpty

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@Test
public void testListNotEmpty() {

	ProjectListPage projectListPage = PageFactory.initElements(driver, ProjectListPage.class);
	Boolean isEmpty = projectListPage.checkIfListItemIsEmpty();
	
	assertTrue(isEmpty);
}
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:9,代码来源:ProjectListTest.java

示例15: testSubmitEmptyForm

import org.openqa.selenium.support.PageFactory; //导入依赖的package包/类
@Test
public void testSubmitEmptyForm() {
	ApplicationListPage applicationListPage = PageFactory.initElements(driver, ApplicationListPage.class);
    applicationListPage.clickAddButton();
    
    ApplicationCreatePage applicationCreatePage = PageFactory.initElements(driver, ApplicationCreatePage.class);
    applicationCreatePage.submitForm();
    assertThat(applicationCreatePage.isErrorMessageDisplayed(), is(true));
}
 
开发者ID:elimu-ai,项目名称:webapp,代码行数:10,代码来源:ApplicationCreateTest.java


注:本文中的org.openqa.selenium.support.PageFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。