Skip to main content
8 votes
Accepted

Selenium PageFactory vs Page Object Model

Page Object and Selenium's PageFactory are distinct things in nature, usually the latter complement the former. Page Object is a design pattern aimed at solving the problem of separating the ...
João Farias's user avatar
  • 10.9k
7 votes
Accepted

POM vs PageFactory

I think the Page Factory is an extension of the Page Object Model. This Selenium documentation page describes with examples what the Factory adds. If you use the PageFactory, you can assume that ...
Niels van Reijmersdal's user avatar
4 votes
Accepted

Does page factory pattern improve Selenium test performance

Design pattern is not a magic ingredient which makes code perform better. It's goal is to make code easier to understand for a programmer (by pushing some effort to organize function calls/data/etc to ...
Peter M. - stands for Monica's user avatar
4 votes
Accepted

How to parameterize @findBy in pageFactory

Unfortunately, it's not possible to send arguments to annotation (reference) One possible solution would be to create a Page Object class for link and pass a WebElement based on its li node. Class ...
João Farias's user avatar
  • 10.9k
3 votes
Accepted

Replacement of @Findby in pagefactory for dynamic value with locator

Do you really want to test that the text Welcome is there? You say the identifiers are dynamic. In these situations, I always suggest to talk to the developers and make it better testable. Preferably ...
Niels van Reijmersdal's user avatar
3 votes

PageFactory is deprecated in C# (.NET) - what to use instead of that

Here is the post where Jim Evans (the maintainer of C# Selenium binding) explains the issue you mentioned. In short: Its only now that I have started to write Selenium tests in C# that I understand ...
Alexey R.'s user avatar
  • 11.6k
3 votes

I created a small POM framework in selenium but it doesnt seem to be recognizing my locators in the Test and also multiple browsers are opened

If you want to use the PageFactory @FindBy annotation you also need to initialize them with PageFactory.initElements(driver, this);. Actually you create 3 browsers, but one gets closed instantly in ...
Niels van Reijmersdal's user avatar
2 votes

Does page factory pattern improve Selenium test performance

Two key reasons to use a Page Factory: To centralize the code that creates the objects in one place instead of repeating the same code every time you need an object To use lightweight techniques to ...
Michael Durrant's user avatar
2 votes

How to locate "Login" button of Flipkart bootstrap login page? I tried in many ways, but still unable to locate element

I guess the "Login & Signup" button itself was not clicked and you would have got some error like, "Element is not clickable at point(x,y)..." Try this code, driver.findElementByXPath("//div[@...
Shanmuga Priya Vittal's user avatar
2 votes

How to locate "Login" button of Flipkart bootstrap login page? I tried in many ways, but still unable to locate element

Try using the following code for login functionality in Flipkart: driver.findElement(By.linkText("Login & Signup")).click(); driver.findElement(By.className("_2zrpKA")).sendKeys(" YOUR USER NAME"...
Kannathasan's user avatar
2 votes
Accepted

POM: driver is passed as an argument? Always?

I appreciate that author's contribution to the people's global knowledge sharing but I have doubt on how well he mastered his Java skills at least because of he doesn't adhere coding style convention ...
Alexey R.'s user avatar
  • 11.6k
2 votes

How to pass the data provider data when page factory method is applied

If I have understood your question correctly, then following are the changes that you need to do: 1. The method setfirstname is not a Test method, so remove the @Test annotation. 2. The method valid ...
Shamanth's user avatar
  • 146
2 votes

Replacement of @Findby in pagefactory for dynamic value with locator

The page object model is a design pattern that describes the best approach for modeling a test automation framework when it comes to web automation. The @FindBy() annotation is just a shortcut ...
Moro's user avatar
  • 1,052
2 votes

How to assert that particular element is not displayed?

If I understand correctly - You want to check if some particular WebElement is missing. While doing so you get a NoSuchElementException. The solution here will be to create a function that returns a ...
Moro's user avatar
  • 1,052
2 votes

The name PageFactory does not exist in current context

The PageFactory class is now considered deprecated in the Selenium binaries; that could be the issue. But, I would still try adding the following to your code to see if it will resolve. using OpenQA....
Brian's user avatar
  • 584
2 votes

Why is WebDriver instance declared static in Page Object model structure in Selenium?

Basically you do not even need to store your driver reference in page class field unless you access some driver-specific features within the logic of your page class (like accessing page title, window ...
Alexey R.'s user avatar
  • 11.6k
2 votes

What is the purpose of creating a BaseTest class which declares a global static WebDriver object in POM framework?

In your code, I think you have mixed two approaches together. Using Base Class Without Using Base Class In Approach 1: You don't have to assign a driver to a local variable if you are using a base ...
PDHide's user avatar
  • 11.1k
1 vote

How to get value of WebElement init in PageFactory?

If this is really what you need you can obtain the value of foundBy field of the RemoteWebElement using Java Reflection API Example code: java.lang.reflect.Field field = panel.getClass()....
Dmitri T's user avatar
  • 13.5k
1 vote

How to get value of WebElement init in PageFactory?

Unfortunately you can not. You can see the WebElement interface here. The closest you can do is to call getAttribute and you could extract an ID or a specific class name. However, you can create a ...
João Farias's user avatar
  • 10.9k
1 vote

Null PointerException on TESTNG ,pagefactory

Selenium will instantiate a WebElement object when you call PageFactory.initElements(driver, LaunchURLRepository.class) Before this statement, any interaction with the WebElement attributes will ...
João Farias's user avatar
  • 10.9k
1 vote

POM + PF on project with web and responsive mobile web

I would look how far I can get with the current page objects and their selectors. Hopefully I can reuse most of the selectors. If not, I have to write new ones. These I would locate in the same page ...
globalworming's user avatar
1 vote

Selenium WebDriver "Cannot instantiate class " error is coming

Judging by this: Java.lang.NullPointerException at java.io.FileInputStream.(Unknown Source) at java.io.FileInputStream.(Unknown Source) at com.mercury.qa.base.BaseTest.(BaseTest.java:26) ...
Moro's user avatar
  • 1,052
1 vote

What is the good practice to instantiate page object in POM and PageObjectFactory?

Both options are fine, but you can improve it in two ways: Abstract the creation to a setup method on the test class, assuming each class is related to each application page. Abstract the factory ...
João Farias's user avatar
  • 10.9k
1 vote

Scrape items from an HTML list

This kinda works: Obviously, that's one result -- I would want to iterate the list for all results. One angle is just to see what's possible from withing basex itself. I believe it can grab the html ...
Thufir's user avatar
  • 367
1 vote

Page Object Model: need help with tests that uses more than 1 page object - Appium-Java-TestNG

It's been a long time since I worked with Java so my code suggestions are going to be more pseudo-code than full code. That said, the way to handle this situation is to have your page object methods ...
Kate Paulk's user avatar
  • 31.5k
1 vote

How can I keep the variable alive across the project globally?

You can have a static class called TestData, which will hold the test user. public final class TestData { @Getter private static String testUser; public static void resetTestUser() { ...
João Farias's user avatar
  • 10.9k
1 vote

How to parameterize locator in Selenium

If I got you right you have the case like this: If yes, then you can define all the items in the container in the way Selenium provides to define page objects and then iterate through the items from ...
Alexey R.'s user avatar
  • 11.6k
1 vote

Using different sets of page objects with the same selenium tests

From your question, it looks like applying the Dependency Injection (https://en.wikipedia.org/wiki/Dependency_injection) may solve the issue. That means that you will need to program against the ...
501NotImplemented's user avatar
1 vote

Using different sets of page objects with the same selenium tests

Test Executors have nothing to do with how you tell Selenium which objects to use. Personally I do not see any benefit of using PageFactory in the situation like yours. Having stuck to page objects ...
Alexey R.'s user avatar
  • 11.6k
1 vote

What are the other ways of storing and accessing the webelement(locators) during automation testing

If you are up for using Ruby say, you could: store the name and locators as key-value pairs in a .yml file Create a Page Object class with an initialize method that read the YAML file and ...
Michael Durrant's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible