Tag Info

Hot answers tagged

13

I find the Page Object pattern very useful, and use a modified PageFactory (parameterized for custom timeouts). I also use WidgetObjects (basically, PageObjects with a parent reference via constructor) to represent common themes across pages. I don't think URL association is necessary on all pages, so I keep it out of my base class. URL params? I keep ...


4

Advantages: Clear separation between test code and navigation code in code base. Easy to comprehend test, for example - Homepage.testLogin(username, password); is more succinct than selenium.type(username); selenium.type(password); selenium.click(submit); selenium.waitForpageToLoad(waitPeriod); Ease of maintenance, when UI changes you need to ...


4

Read this ( scroll down to the page objects section though the whole page us good ) and this for some background Or from this page Taking it back to basics, essentially there are three functions I see a page object pattern provides: Ability to easily instantiate pages in a consistent manner Ability to concisely describe elements on a page, ...


3

There are times when using the Page Object Pattern makes a lot of sense and times where it doesn't make as much sense. If you have a web application where it is basically one single dynamic page then it makes less sense, however you can still use "page" objects that are really more like "section" objects for common pieces, for example if you have a Left ...


3

I actually wrote that library while I was at a company creating automation for them. I had plans to open source it, but unfortunately never was able to and have since moved to a different company. In the presentation I was using the library I created, however you can build your own abstraction layer that does many of the things I talked about as well, or ...


3

I do not know which ''this'' you are referring to when you ask, "Am I getting all this wrong?" According to the Wiki page, the isLoaded method should use JUnit assertions to check whether the page is actually loaded. JUnit assertions throw Errors, not exceptions, to signal that something went wrong. LoadableComponent could have refactored isLoaded into ...


3

My answers below are based on the framework that we've built, which uses a state machine to traverse the application we're testing. The URL (or, rather, a compiled regex representing the URL) is indeed a property of the individual page objects in my test suite. They all descend from a base page object very similar to terryp's (though we've converted to ...


3

After spending some more time with WebDriverWait, I came out with something nicer: Client code: /** Page Object. */ public class Page { private WebElement mySelect; public Page setMySelect(String optionText) { String optXpath = String.format("./option[text()='%s']", optionText); mySelect.click(); ...


2

I use Python and Selenium 1 and find page objects very useful. Mostly don't care about the URL. I check the page contents to make sure I'm where I expect. Most of the fields in my page objects relate to form fields on the page. I also have object fields that can read bits of static text based on the DOM. I have a base class with a variety of utility ...


2

I write my Selenium tests in Clojure, a Lisp that runs on the JVM. While it is possible to define objects in Clojure, it makes more sense to organize Lisp code using functions rather than objects, so my tests are all written as functions with the occasional closure. (I mention Clojure to put into context why I don't use page objects, not as an endorsement ...


1

There are two parts to this. The first is that you need to be sure that your xPath is correct. One way to validate that is to use a tool like Firefinder (a firefox extension for firebug). Navigate to your page and be sure the element you need is present and then hit f12 and go to the FireFinder section. Enter in the xpath you are using and see if it can ...


1

Can you find it if you use the .Text and then clicking it if it matches? String Expectedtext = "Procurement" String ProcurementButtonText = driver.FindElement(By.XPath("//td")).Text; if (ProcurementButtonText == Expectedtext) { driver.FindElement(By.XPath("//td")).click() }


1

Often times on extremely dynamic pages, I don't simply have a list of elements in my page object, instead I will implement helper functions that will interact with the dynamic data/elements on the page. For example, if there you are testing an e-mail inbox instead of creating elements for message1, message2, message3, etc instead I would implement a ...


1

Your question hints at a couple of questions: What Is a Page Object? A page object is code written to model an actual page (or part of a page) in a web application. Eg. each page in your app, would have an associated page object file that provides the “services” that the actual page offers. Eg. if there’s a button on a page in your application, you would ...


1

Given that you can't return a page object, you might have each test stuff its last page object into a member variable, so that the next test can access it. This is ugly, of course, because it increases the dependence between tests, and does so in a not-exactly-obvious way. But the results might give ideas about what to do next. And if it's too ugly you can ...


1

I'm using the inherited based design. It worked great until the application I'm testing was also made available in another, more limited customer-facing UI. So now I have two applications which consist of the same components surrounded by different menus. That's a situation where the inherited design breaks. An aggregation-based design combined with some ...


1

Is a page URL a property of the Page Object ? What if a number of different URLs lead to the same page ? Also, what if the URL is used to pass some parameters, do you if at all deal with that ? Most of my pages don't know (or care) about the URLs that lead to them. When I have pages that I want to jump to directly (rather than navigating to by ...



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