public final class ElementFactory
extends java.lang.Object
PageFactory| Modifier and Type | Method and Description |
|---|---|
static void |
initElements(org.openqa.selenium.support.pagefactory.FieldDecorator decorator,
java.lang.Object page)
see
PageFactory.initElements(org.openqa.selenium.support.pagefactory.ElementLocatorFactory, Object) |
static <T> T |
initElements(org.openqa.selenium.WebDriver driver,
java.lang.Class<T> pageClassToProxy,
java.lang.String pageName,
java.lang.String contextDescription)
Instantiate an instance of the given class, and set a lazy proxy for each
of the WebElement and List<WebElement> fields that have been
declared, assuming that the field name is also the HTML element's "id" or
"name".
|
static void |
initElements(org.openqa.selenium.WebDriver webDriver,
org.openqa.selenium.support.pagefactory.ElementLocatorFactory factory,
java.lang.Object page,
java.lang.String pageName,
java.lang.String contextDescription)
Similar to the other "initElements" methods, but takes an
ElementLocatorFactory which is used for providing the mechanism
for fniding elements. |
static <T> T |
initElements(org.openqa.selenium.WebDriver webDriver,
T page,
java.lang.String pageName,
java.lang.String contextDescription)
As
initElements(WebDriver, Class, String, String)
but will only replace the fields of an already instantiated Page Object. |
public static <T> T initElements(org.openqa.selenium.WebDriver driver,
java.lang.Class<T> pageClassToProxy,
java.lang.String pageName,
java.lang.String contextDescription)
public class Page { private WebElement submit; }
there will be an element that can be located using the xpath expression
"//*[@id='submit']" or "//*[@name='submit']"
By default, the element or the list is looked up each and every time a
method is called upon it. To change this behaviour, simply annotate the
field with the CacheLookup. To change how the element is located,
use the FindBy annotation.
This method will attempt to instantiate the class given to it, preferably
using a constructor which takes a WebDriver instance as its only argument
or falling back on a no-arg constructor. An exception will be thrown if
the class cannot be instantiated.driver - The driver that will be used to look up the elementspageClassToProxy - A class which will be initialised.pageName - name of the page where the element is.contextDescription - description of the context.FindBy,
CacheLookuppublic static <T> T initElements(org.openqa.selenium.WebDriver webDriver,
T page,
java.lang.String pageName,
java.lang.String contextDescription)
initElements(WebDriver, Class, String, String)
but will only replace the fields of an already instantiated Page Object.webDriver - The driver that will be used to look up the elementspage - The object with WebElement and List<WebElement> fields
that should be proxied.pageName - name of the page where the element is.contextDescription - description of the context.public static void initElements(org.openqa.selenium.WebDriver webDriver,
org.openqa.selenium.support.pagefactory.ElementLocatorFactory factory,
java.lang.Object page,
java.lang.String pageName,
java.lang.String contextDescription)
ElementLocatorFactory which is used for providing the mechanism
for fniding elements. If the ElementLocatorFactory returns null then the
field won't be decorated.factory - The factory to usepage - The object to decorate the fields ofpageName - name of the page where the element is.contextDescription - description of the context.public static void initElements(org.openqa.selenium.support.pagefactory.FieldDecorator decorator,
java.lang.Object page)
PageFactory.initElements(org.openqa.selenium.support.pagefactory.ElementLocatorFactory, Object)Copyright © 2017 PPI AG. All rights reserved.