Hot answers tagged

9

The PageObject Model is not a framework. A framework is: a basic structure underlying a system The Page Object Model is: an object repository design pattern here. Using the POM might result in a personal testing framework as it creates a part of the underlying structure for your tests. but Data Driven because you always need to extract data from a ...


7

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 the fields are initialised. If you don't use the PageFactory, then NullPointerExceptions will be thrown if you make the assumption that the fields are ...


5

If you think about what a method actually is (a procedure specific to that class to achieve a certain result or get a value) then I would use a single Login method. Having a one-on-one relation between methods and individual elements is not doable for larger pages, and it will make your test methods very long. My PageObjects usually have at least these same ...


4

After a long hard fought battle, I was able to overcome this using opposite of what K-8 had suggested. Instead of checking if an element is visible on the viewport, I checked the negative of that, which is if element is not visible on the viewport. So, I did this public waitForSpinnerDisappear(){ let EC = protractor.ExpectedConditions; browser.wait(EC....


3

As others have said, the Page Object Model is a design pattern which helps to avoid repeated code. A Framework is a code platform providing a base set of generic functionality and guidelines for implementation. You implement design patterns within frameworks - so you might use a keyword-driven framework with the Page Object Model, for example. Or a ...


2

This is probably not a design pattern but more like an organizational/structural pattern. When having a big test codebase and following the Page Object pattern for WebDriverJS/Protractor testing, we've found out that having a complex Page Object defined as a node "package" (directory with index.js as a main entry point) with child page object exposed ...


2

The testng.xml should be located in your test resources. That way the testng.xml will be copied. You can also configure surefire plugin to explicitly run testng suite xml files. Should your maven plugins be configured as plugins not dependencies? Also seems like you should have other dependencies in test scope as well. Be sure to check that your test ...


2

This is not possible. Since Java annotations does not allow dynamic parameterization. For more details check this answer.


2

You haven't loaded your file to properties object hence you get null when try to obtain a property value. Your code should look like public TestBase() { try { prop = new Properties(); FileInputStream ip = new FileInputStream("/Users/rasha011/Dev/Parabankparasoft/src/main/java/com/parabank/qa/config/config.properties"); ...


2

Only program the actions (class methods) you really need. Apply the YAGNI principle. Don't write code you think you might need in the future, this will only add maintenance as you write more code than needed. Make sure the tests are readable and describe the user behaviour. So in the example case you give, the user behavioural action is to login. So one ...


2

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 management, etc.) As to me the latter is better to take out (I consider using driver object within a page class methods as a sort of anti-pattern) of page ...


2

Another way to phrase this question is, "How do multiple developers use the same code base in their work?" Selenium automation is just using an open source library to set up testing. It's not any different to what your developers do in your teams codebase. The process and setup are the same. What does that look like? Ensure the Selenium project is ...


1

it's a bit embarrassing, (because i remembered I did this before) After doing an mvn clean, and an mvn compile again, Then the issue disappeared. something probably got stuck somewhere and needed a clean again..


1

there is a best practice when "There are good practices in context, but there are no best practices." When you first create the LoginPage object, it has the context of the first landing on the page. It may have loaded internal information relevant to this first landing (which the tests don't need to know). When you perform login and logout and ...


1

I don't think it is the best practice to pass your web-Driver as a parameter and pass it to every single method. Don't create method for returning the web-Elements , Instead Use PageFactory or your By class at the top of your page class . If possible separate your webElement from your page , Keep them in Some separate file. SO in Future if your WebElement ...


1

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 class Avoid: public class LoginTest extends BaseTest{ public WebDriver driver; public LoginTest(){ this.driver = BaseTest.driver } instead use public ...


1

Using static will make the scope class level, else the scope will be the object level. You cannot share the state between classes You can use base class driver instance by inheriting it or by calling Baseclass.driver then you need static keyword.


1

I am not sure that you have provided a proper code or you have right understanding of where your exception appears. As per your code: { instance = DriverInstance.getinstance(); driver = instance.getDiver(); wait = instance.getWait(); } you get a reference to a static field instance = DriverInstance.getinstance(); that is basically you can read ...


1

Java's built in Function interface allows me to avoid using getters. Instead of hardcoding each property in a separate field, I use a TreeMap to hold all the properties as property name and property value. A second TreeMap links properties to scraping methods. The data type is String but I could also use a TreeMap as the value type within the first Treemap, ...


1

You are right to be concerned about getters/setters; they are an anti-pattern in OOP and should be avoided because they result in more tightly coupled code Instead invert the responsibility by using the tell don't ask idiom. In this case use an expected data manager. Create a Batch class that reflects the expected data and pass this expectedData to the ...


1

Delete .m2 folder which contains all the dependencies form your user-home.Then re-build your package using "mvn clean package" command.All your dependencies will be removed and when you run a maven project ,the required dependencies will get downloaded and again stored in your local repository(.m2).


1

mvn clean means you're executing the clean phase of maven which would not run any tests. You should probably try test or verify, e.g. mvn clean verify. More to read: https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html


1

If controls are used only together (it does not make sense to fill/click one but not the other), handle them in a single method. If they can be used separately, handle them in separate methods. Possibly provide reasonable defaults. PageObjects provide services for tests. Design them in a way so writing tests is easier. Encapsulate all the info about the ...


1

I can see you are getting little confuse between Page Object Model and Data driven/Hybrid. Below small info might help to understand basic - What framework is Page Object Model? Simply its one of the design pattern type It helps to create Object Repository for UI elements In POM, for each web page in the application there should be corresponding page ...


1

We often call POM a framework but its mostly is a design pattern/class style to create object repository. You can make it Hybrid by adding even other testing process... like- adding cucumber-jvm to partially do some behavioral driven testing. And also data driven with Apache POI or using DataProvider.


1

At this point its worth building a user data generator that can be used to provide coherent sets of login data and credentials for your tests. Something like faker https://github.com/DiUS/java-faker would do the job and can be customised to fit your needs. It could later be rolled into a service to support CI environments. By having a point that tests go ...


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