8

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 application interface from the HTML interface. Why do we separate these interfaces? Because web pages elements and functions, as saw by the user, differ from the HTML ...


3

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 developers and testers write and maintain the end-to-end tests together. Let them feel your pain. Now when in application developer change welcome to ...


2

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 boolean value if an element is present. Something like this: public boolean isPresent(By locator) { try { webDriver.findElement(locator); ...


1

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 provided to developers by the PageFactory class. Use of the @FindBy() annotation is not mandatory for you to use the page object principles. You can still model your ...


1

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().getDeclaredField("foundBy"); field.setAccessible(true); String foundBy = field.get(element).toString(); But remember when you bypass Java encapsulation using reflection ...


1

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 wrapper over WebElement that stores the locator: public class RefreshableWebElement implements WebElement { ... public RefreshableWebElement(Driver ...


1

Selenium will instantiate a WebElement object when you call PageFactory.initElements(driver, LaunchURLRepository.class) Before this statement, any interaction with the WebElement attributes will result in a NullPointerException. More details on the Selenium Wiki and the Javadoc of this method here.


1

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 object, because the "page" itself does not change, just how it looks. Readability is bad either way, you either have HomePage vs MobileHomePage or searchInput vs ...


1

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) at com.mercury.qa.testcase.LoginPageTest.(LoginPageTest.java:18) ... 26 more } The properties file cannot be found - you should fix the path, or create a ...


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