Questions tagged [page-factory]

PageFactory is a Selenium class which provides a means to instantiate a page object model/pattern by initializing all defined web elements

The PageFactory Class in Selenium is an extension to the Page Object design pattern. It is used to initialize the elements of the Page Object or instantiate the Page Objects itself. It is used to initialize elements of a Page class without having to use FindElement or FindElements.

177 questions
37
votes
7 answers

Selenium @FindBy vs driver.findElement()

Why should I use @FindBy vs driver.findElement()? @FindBy forces me to move all my variables to a class level (when most of them only need to be at the method level). The only thing it seems to buy me is I can call PageFactory.initElements(), which…
17
votes
3 answers

StaleElementReference Exception in PageFactory

I am trying to learn the PageFactory model. I understood the fact that when we do a initElements, the WebElements are located. Say for example, I click on a webelement and because of which there is a change in one of the other webelements in DOM.…
10
votes
8 answers

The name 'PageFactory' does not exist in the current context

I'm creating a test automation framework in c#. At the top of the project I have "using OpenQA.Selenium.Support.PageObjects;", however when I try to reference PageFactory.initElements(driver, PageName) I'm seeing the message "The name 'PageFactory'…
Brad White
  • 121
  • 1
  • 1
  • 7
7
votes
2 answers

Fetch Pagefactory WebElement name using reflection

I am using selenium pagefactory, and have introduced an annotation @Name(Description = "Username"), which I use for all WebElements. I need to find the value for Description in my custom methods later on, for reporting, like: public static void…
6
votes
5 answers

Appium - Getting a java.lang.RuntimeException: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy9.proxyClassLookup() at PageFactory

I am getting this exception on running an Appium test. The test fails at PageFactory with the exception below. My POM:
Sheetal
  • 63
  • 1
  • 5
5
votes
4 answers

How to wait for invisibility of an element through PageFactory using Selenium and Java

Is there a way to wait for an element not present in Selenium using PageFactory annotations? When using: @FindBy(css= '#loading-content') WebElement pleaseWait; to locate the element, and…
Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
4
votes
2 answers

How to implement AjaxElementLocatorFactory through Selenium and Page Factory?

I've used Pagefactory to set up all of my pages in Selenium. The thing is the test are dynamic in that some elements only exist in some of the test. From m understanding AjaxElementFactory works like this: PageFactory.initElements(new…
3
votes
2 answers

How to handle dynamic elements in Page Object Model in Selenium?

Is it possible to handle dynamic elements in Page Object Model? Example: package pages; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import…
3
votes
4 answers

Handle StaleElementReferenceException while using PageFactory

While using Pagefactory I am directly declaring WebElement as below. @AndroidFindBy(accessibility = "androidLocator") @iOSFindBy(accessibility = "iosLocator") private MobileElement element; But, is there a way out to handle StaleElementReference…
3
votes
1 answer

Cannot invoke sendKeys(String) on the primitive type void

I am new to selenium and I am implementing a data driven frame work using page factory and keep getting the following error: Cannot invoke sendKeys(String) on the primitive type void when trying to set my test script- for the following: String…
nchll
  • 53
  • 1
  • 5
3
votes
3 answers

Pass value to xpath at runtime

Please read the whole Q before disliking or commenting something. I have searched on internet before posting it here. I'm having the below project structure. pages(package) > Homepage.java test(package) > Flipkart.java Inside Homepage.java…
Sandeep Raulo
  • 154
  • 1
  • 5
  • 21
2
votes
2 answers

Use visibilityOfElementLocated with pagefactory

I'm writing automated scripts using page factory and I want to use visibilityOfElementLocated with page factory instead of visibilityOf I tried to use visibilityOf but some times it not work with my element the problem here that…
2
votes
1 answer

Different ways of initializing PageObjects using PageFactory

I'm trying to build a Cucumber Java framework in Page Object Model. I have created the base framework and it works fine, but got confused how to initialize the pages. I have noticed that in most of the tutorials they have initialized the pages in…
zeal
  • 475
  • 4
  • 11
  • 25
2
votes
2 answers

Code not executing when placed in separate test classes

I am wring a PageFactory framework for a website using maven+TestNG, I have page wise PageObject classes where all web elements and actions specific to page are present like LoginPageObject, AccountSelectionPageObject... I have a class "Base" where…
Rajaji
  • 133
  • 2
  • 14
2
votes
3 answers

Getting java.lang.NullPointerException in POM uisng page Factory

I've posted below some sample code which I've done so far and I'm getting an Exception java.lang.NullPointerException. Base Class: public class TestBase { public static WebDriver driver= null; @BeforeSuite public void initialize(){ …
vijayateke
  • 77
  • 1
  • 10
1
2 3
11 12