當前位置: 首頁>>代碼示例>>Java>>正文


Java PageFactory.initElements方法代碼示例

本文整理匯總了Java中org.openqa.selenium.support.PageFactory.initElements方法的典型用法代碼示例。如果您正苦於以下問題:Java PageFactory.initElements方法的具體用法?Java PageFactory.initElements怎麽用?Java PageFactory.initElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openqa.selenium.support.PageFactory的用法示例。


在下文中一共展示了PageFactory.initElements方法的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: 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

示例5: 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

示例6: RiotContactPickerPageObjects

import org.openqa.selenium.support.PageFactory; //導入方法依賴的package包/類
public RiotContactPickerPageObjects(AppiumDriver<MobileElement> myDriver) throws InterruptedException{
	driver=(AndroidDriver<MobileElement>) myDriver;
	PageFactory.initElements(new AppiumFieldDecorator(myDriver), this);
	try {
		waitUntilDisplayed((AndroidDriver<MobileElement>) driver,"im.vector.alpha:id/decor_content_parent", true, 5);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}
 
開發者ID:vector-im,項目名稱:riot-automated-tests,代碼行數:10,代碼來源:RiotContactPickerPageObjects.java

示例7: testEdit

import org.openqa.selenium.support.PageFactory; //導入方法依賴的package包/類
@Test
public void testEdit() {
	AllophoneListPage allophoneListPage = PageFactory.initElements(driver, AllophoneListPage.class);
    if (allophoneListPage.getListCount() > 0) {
        allophoneListPage.clickRandomEditLink();

        AllophoneEditPage allophoneEditPage = PageFactory.initElements(driver, AllophoneEditPage.class);
        allophoneEditPage.submitForm();

        PageFactory.initElements(driver, AllophoneListPage.class);
    }
}
 
開發者ID:elimu-ai,項目名稱:webapp,代碼行數:13,代碼來源:AllophoneEditTest.java

示例8: testSubmitEmptyForm

import org.openqa.selenium.support.PageFactory; //導入方法依賴的package包/類
@Test
public void testSubmitEmptyForm() {
	WordListPage wordListPage = PageFactory.initElements(driver, WordListPage.class);
    wordListPage.clickAddButton();
    
    WordCreatePage wordCreatePage = PageFactory.initElements(driver, WordCreatePage.class);
    wordCreatePage.submitForm();
    assertThat(wordCreatePage.isErrorMessageDisplayed(), is(true));
}
 
開發者ID:elimu-ai,項目名稱:webapp,代碼行數:10,代碼來源:WordCreateTest.java

示例9: 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

示例10: 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,代碼來源:AbilityIT.java

示例11: 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

示例12: RiotRoomDetailsPageObjects

import org.openqa.selenium.support.PageFactory; //導入方法依賴的package包/類
public RiotRoomDetailsPageObjects(AppiumDriver<MobileElement> myDriver) throws InterruptedException{
	PageFactory.initElements(new AppiumFieldDecorator(myDriver), this);
	driver=(AndroidDriver<MobileElement>) myDriver;
	//ExplicitWait(driver,this.messagesListView);
	//if 'Riot permissions .... Allow Riot to access your contacts' pops up, close it.
	if(waitUntilDisplayed(driver, "//android.widget.TextView[@resource-id='android:id/alertTitle' and @text='Information']", true, 1)){
		driver.findElementById("android:id/button1").click();
	}
	
	try {
		waitUntilDisplayed(driver,"//android.widget.HorizontalScrollView", true, 5);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}
 
開發者ID:vector-im,項目名稱:riot-automated-tests,代碼行數:16,代碼來源:RiotRoomDetailsPageObjects.java

示例13: testSubmitEmptyForm

import org.openqa.selenium.support.PageFactory; //導入方法依賴的package包/類
@Test
public void testSubmitEmptyForm() {
	VideoListPage videoListPage = PageFactory.initElements(driver, VideoListPage.class);
    videoListPage.clickAddButton();
    
    VideoCreatePage videoCreatePage = PageFactory.initElements(driver, VideoCreatePage.class);
    videoCreatePage.submitForm();
    assertThat(videoCreatePage.isErrorMessageDisplayed(), is(true));
}
 
開發者ID:elimu-ai,項目名稱:webapp,代碼行數:10,代碼來源:VideoCreateTest.java

示例14: form

import org.openqa.selenium.support.PageFactory; //導入方法依賴的package包/類
public Form form() {
	if(form != null) {
		return form;
	}
	form = new Form();
	PageFactory.initElements(getDriver(), form);
	return form;
}
 
開發者ID:pivotalsoftware,項目名稱:pivotal-cla,代碼行數:9,代碼來源:SignIclaPage.java

示例15: RiotContactPickerPageObjects

import org.openqa.selenium.support.PageFactory; //導入方法依賴的package包/類
public RiotContactPickerPageObjects(AppiumDriver<MobileElement> myDriver) {
	driver= myDriver;
	PageFactory.initElements(new AppiumFieldDecorator(driver), this);
	try {
		waitUntilDisplayed((IOSDriver<MobileElement>) driver,"ContactsTableVCTableView", true, 5);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}
}
 
開發者ID:vector-im,項目名稱:riot-automated-tests,代碼行數:10,代碼來源:RiotContactPickerPageObjects.java


注:本文中的org.openqa.selenium.support.PageFactory.initElements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。