Hot answers tagged

6

No. Do not just split your pageObject into pageObject2, 3, 4, etc. This goes for all programming - split your classes logically by function, not arbitrarily! Your page object should be the source of truth for that specific page. When you start trying to interact with your page, does it really make sense that you should search between MyForm.java and ...


5

In my opinion, yes, it does. However there isn't really a single way to implement this model that just works. You have to really think about the structure of your website in terms of it's pages, and figure out how you can represent that structure in your code. For one company I worked for, I used the page object model against pages that were very simple ...


4

It all depends what high level operations you have on your page. The requirement of High level functionalities differ from application to application and page to page. Some of the pages may not be having any or some of the options mentioned by you but some may have additional operations like Edit : Change the record to edit mode Delete : Delete the ...


3

I would assert an expected element is present on the returned page using NUnit eg Assert.AreEqual(loginPage.LoginButton.ToString(), "Login"); Common elements to use would be; an ID (unique element on the page) Page Title Contextual (like the example above). Avoid using things like the URL which often contain things like session information ...


3

I think that you should create a page object class for each page of the site. If you have a single page site, you can create page widgets instead of page objects. The page widgets will correspond to components of the web page (example: footer, header, etc). When the number of your page object classes increases, you should create a base class that all page ...


3

Generally architecture of System Tests should comprise Page Objects, Business Layer and Test Cases. The fact that your Page Object gets bigger with the number of the fields makes sense. It will happen. The complexity of Page Objects gets higher with the complexity of UI. All in all you need to keep a mapping to the page somewhere. Even if you find a way to ...


3

I had similar question few years back. At that point I had only seen page object based implementation. In my current company we have a single framework that manages mobile, web, web services. A nice presentation of page object challenges is available in http://www.slideshare.net/abagmar/perils-of-pageobject-pattern. There is also a youtube session on the ...


3

I recommend avoiding external documentation because no one wants to maintain it. Instead, use comments in your code and useful names for your classes and methods. And ask someone to review some of your code specifically with those considerations in mind.


3

We have had a very hard time automating the Google Maps API. Test case: Surf to Google maps: https://www.google.nl/maps Find an area with known location Click the known location (without the use of mouse-coordinates, should also work when zooming, etc...) Verify the location box with details opens Retrieve the phone number This is very hard, because ...


2

@FindBy(css="a[dta-qid='inventory']") I've used that kind of locators in my last project and it's worked like charm. I hope this is that You want :)


2

"Test automation" means more than just automating user interfaces that run in a web browser. Someone with good programming skills should be able to find many other ways to use software to test software. Here are are couple of examples: Write API-level integration tests. If developers test, they probably focus on unit tests. There is a middle ground ...


2

Strategy is automation. Could be: Brutal force: read all values on all pages to a field variable and compare each with it's neighbor. Simple task for test automation. Optimised: sequentional read of the parameter and compare with the previous and next value, regardless of independently switching to the next page, if you reach end of the list. Avoidance: ...


2

Page Objects are great in the right circumstances. They allow growth. Initially when you only have a few fields on one page, they are not of much use. Each field is probably fairly unique already and identifying them is trivial and short. As the application grows the following starts to happen: the same field is in multiple spots on the same page the ...


2

As I understood the question, it is required to define the reusable methods and use those methods in different test cases based on the requirement. Here I am writing the code for two individual methods to work with,... public void inputKeys(WebElement we,String ip){ we.sendKeys(ip); } The above code just type the string value referred by ip variable. ...


2

As always, multiple solutions are possible. Example 1: The most common and perhaps logical example you'll find is the one where navigation is seen as a Browser action. It's not a PageObject method because navigating to a certain URL has nothing to do with the page's content behind it. public void TestMethod() { Browser.GoTo("www.google.com"); ...


2

Page Factory Pattern is like an extension to Page Object Model , but Page Factory is much enhanced model. To start with, we just need to import package org.openqa.selenium.support.PageFactory "Factory class can be used to make using Page Objects simpler and easier". We use Page Factory pattern to initialize web elements which are defined in Page Objects. ...


1

You can try to assert a text in the page you are navigating to. You can also assert page/window title. Another way to assert whether an image or an element specific to that page is present or not.


1

I am only on my phone right now so can't try out any tests for this, but the problem here looks like the findsby attribute for the page object factory in Selenium is expecting to locate and return only a single instance of IWebElement rather than the collection you are trying to have it locate. I'm not sure if there is an additional attribute that tells ...


1

Depending on your coding style and programming language, page object can be very simple. My page objects have only one method to fill form values (or more than one only if input is very complicated, but still just few). And these methods all use universal fill() form, which accepts (optionally ordered) dictionary of locators and values to be filled. And this ...


1

Martin Fowler discussed whether assertions should be included in page objects: There are differences of opinion on whether page objects should include assertions themselves, or just provide data for test scripts to do the assertions. Advocates of including assertions in page objects say that this helps avoid duplication of assertions in test ...


1

Your XPaths localize these elements, because these contain the text you've specified: <td class="first-col">Premium:</td> <td class="first-col">NJ State Tax:</td> You want the next td where the actual values are. In this case, try adding /following-sibling::td, like so: [FindsBy(How = How.XPath, Using = ...


1

My rule of thumb when designing UI tests is to do a basic check that the UI works, but coverage of the exact logic really should be shifted further down the testing pyramid (this will save execution time, plus lower level tests are better suited to it). A simple check of the first and last elements should suffice. That said, if you don't have good coverage ...


1

You said you're using the Page object model to separate your Web code from your orchestration and assertions. Let's not lose that good design principal when designing this test. If you haven't already, abstract a table on your Web page into a collection (eg string[]) on your page object. Find out how to check a string[] is alphabetically ordered, which your ...


1

If all the results are on the same page, it should be pretty straightforward. You'll need to fetch the cell you've sorted, probably require a comparator of some kind, and just verify that each cell is ascending (or descending, as the case may be) from the previous cell. If you're using pagination it's going to be harder. You would need to go through each ...


1

It looks like your driver instance is created in one class(lib, (should start with Capital letter BTW)) but you are trying to access it in another class(KnowledgeBase). If you want to use a class instance in another class, you have options. Some of them are: Add a getter method. Add a public getDriverInstance() method in the class where the instance is ...


1

Yes. It's documented in official documentation. Also you can find an example here to understand better / start with.


1

Page objects can be flexible and should reflect the way you write and maintain your tests. For myself, I typically keep my page objects as compact and stateless as possible. If your pages have a lot of re-usable components, you can put those into smaller classes that encapsulate that functionality independently, then you can use composition to integrate ...


1

I do. I use Python. In page object, I use dictionary to map locator names to locator values. So even if locator value changes, its name stays same. To fill the form, I create good old Dictionary, mapping locator names to values to be filled. Sometimes page fields needs to be filled in exact order, in that case I use Ordered Dictionary. Base page (from ...


1

Yes, it makes sense. To quote Martin Fowler in http://martinfowler.com/bliki/PageObject.html, Despite the term "page" object, these objects shouldn't usually be built for each page, but rather for the significant elements on a page. So a page showing multiple albums would have an album list page object containing several album page objects. There would ...


1

Considering your focus on atomic page operations, I would add some basic operations on popups, like ClosePopup, AcceptPopup, CancelPopup. Perhaps depending on the technology you should add some extra functions.



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