Announcing robotframework-pageobjects Library

690 views
Skip to first unread message

Aaron Cohen

unread,
Nov 10, 2014, 12:06:33 PM11/10/14
to robotframe...@googlegroups.com
Hi, the organization I work for, National Center for Biological Information has released a Robot Library called robotframework-pageobjects. The library adds support for true "page objects" in Robot/Selenium2Library tests.

The main point of using page objects is to factor out page implementation details (locators, UI details etc.) from the actual test suites. This makes the tests read more about the services a page offers and what's being tested instead of the internals of the page. It also makes your tests much more maintainable. For example, if a developer changes an element ID, you only need make that change once--in the appropriate page object.

Each page object is simply a Robot library that inherits from this package's base Page class. These library classes can work independently of Robot Framework, even though they ultimately inherit from Robot Framework's Selenium2Library. This allows you to write page objects using Selenium2Library as a base, but still use those page objects in any testing framework, including Python unittest test cases.

For organizations initially leery of using Robot, this is a great selling point. Have your cake and eat it too!

https://github.com/ncbi/robotframework-pageobjects

Trent Himes

unread,
Nov 10, 2014, 6:29:17 PM11/10/14
to robotframe...@googlegroups.com
I'm getting the following error when I try to install: ValueError: Cannot find the version number!

Am I doing something wrong?

David

unread,
Nov 10, 2014, 6:44:40 PM11/10/14
to robotframe...@googlegroups.com
This seems nice to have :)

I wonder whether there is value for a port for the Java version of Selenium2Library since there are also a lot of users of Java, and such could assist in steering them to considering RF rather than stick with Java based test frameworks.

Aaron Cohen

unread,
Nov 10, 2014, 9:24:09 PM11/10/14
to robotframe...@googlegroups.com
Are you doing

$ pip install robotframework-pageobjects
?

I just tried that on my machine and it worked.

I'm not really online again until tomorrow mid-day, so I'll have to look at it then.,

Aaron Cohen

unread,
Nov 10, 2014, 9:25:41 PM11/10/14
to robotframe...@googlegroups.com
Maybe. I'm not interested in porting it for Java though...Let's see if people use it in Python first. We put a lot of work into this. I would have loved to have had it out-of-the-box.

Aaron Cohen

unread,
Nov 11, 2014, 9:04:23 AM11/11/14
to robotframe...@googlegroups.com
About the ValueError, that's probably because you are cloning it and then installing. We'll look into this. Are setup.py was written for our local releases, so it's probably not quite right, but I put the package on PyPi, ,so you should be able to just run:

$ pip install robotframework-pageobjects

That works for me. Did you try that yet?

Trent Himes

unread,
Nov 11, 2014, 11:50:25 AM11/11/14
to robotframe...@googlegroups.com
That didn't work. This is the error I get: Could not find a version that satisfies the requirement robotframework-pageobjects (from versions: 0.4-316-g476a)

I'm pretty excited about using this - I was working on a pure Python test framework previously and we used a page object system ourselves. Thank you for making this. :)

Trent Himes

unread,
Nov 11, 2014, 12:00:31 PM11/11/14
to robotframe...@googlegroups.com
In case this helps...
I'm using Python 2.7.6 with setuptools 7.0. I don't have any Git packages or plugins installed. I use Pycharm to develop in.

Bryan Oakley

unread,
Nov 11, 2014, 1:00:26 PM11/11/14
to trent...@gmail.com, robotframework-users
I'm having the same issues on my mac -- pip install robotframework-pageobjects yields "Could not find a version that satisfies the requirement robotframework-pageobjects (from versions: 0.4-316-g476a)", and cloning the repository and doing "pip install ." yields "ValueError: Cannot find the version number!"


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Bryan Oakley

unread,
Nov 11, 2014, 1:05:25 PM11/11/14
to trent...@gmail.com, robotframework-users
Looking at the pip install log, it said this:


Sure enough, if I did "pip install --pre robotframework-pageobjects", it installed just fine. 

Trent Himes

unread,
Nov 11, 2014, 3:26:20 PM11/11/14
to robotframe...@googlegroups.com, trent...@gmail.com
Yup. That worked for me too. Thank you!
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Aaron Cohen

unread,
Nov 12, 2014, 5:16:14 PM11/12/14
to robotframe...@googlegroups.com, trent...@gmail.com
OK we released version 1.0 on PyPi. So now you shouldn't have to use that --pre flag.

Aaron Cohen

unread,
Dec 5, 2014, 1:52:07 PM12/5/14
to robotframe...@googlegroups.com
I wrote up a blog post about our experience choosing Robot Framework for our testing purposes, developing the robotframework-pageobjects library and integrating it into our QA group's processes.

Bryan Oakley

unread,
Dec 5, 2014, 2:16:41 PM12/5/14
to Aaron Cohen, robotframework-users
_Very_ interesting read. Thanks for taking the time to write that up. I'm going to need to carve away more time to study your page objects code. 

My biggest concern (which I mentioned earlier, and which I think you may have parly addressed...) is the documentation of the page object keywords. I've found that one of our biggest problems in getting people to write good tests is that they don't know which keywords are available or how to use them (and more importantly, which low level keywords aren't designed to be used directly in test cases). How do you guys provide that information to your testers? Are they required to be able to read the python code that implements the page object for a page?

I would love to work with you guys to find a way to get robotframework-hub (https://github.com/boakley/robotframework-hub) to work well with page objects. Imagine being able to use the search feature to search for a page, and get a list of all of the keywords you can use to interact with that page. 


On Fri, Dec 5, 2014 at 12:52 PM, Aaron Cohen <kahun...@gmail.com> wrote:
I wrote up a blog post about our experience choosing Robot Framework for our testing purposes, developing the robotframework-pageobjects library and integrating it into our QA group's processes.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Gu Ru

unread,
Dec 5, 2014, 5:46:57 PM12/5/14
to robotframe...@googlegroups.com
Thank you very much for the pageobject library and the blog. I had been experimenting with it

I had required, at times, as a hack, to "find elements", in a page based on a expression of css selector. I believe we donot have a keyword corresponding to find_elements in Selenium2Library (its for a good reason)

One advantage (or a note)  I see is, internal method, for e.g Page._element_find( locator, False, False) can be accessed from extended pageobject.py for a webapp. The testcase will remain unaffected

Aaron Cohen

unread,
Dec 6, 2014, 8:27:25 PM12/6/14
to Bryan Oakley, robotframework-users
Thanks Bryan. We did address the libdoc issue, which allows you to run libdoc against this package, or any of your libraries that inherit from it. Our library defines the "not_keyword" decorator, which you can use with keywords you don't want to expose to actual testers. See https://github.com/ncbi/robotframework-pageobjects/blob/23597cd0c5641ba327e970e1749116be0ed89cef/robotpageobjects/base.py and search for "not_keyword".

Our organization is currently building up our page object libraries, and the main authors are our QA group. We don't expect non-technical folk to write page objects in Python, but, rather, eventually to use existing keywords once our page objects are built up enough. Of course they will probably always need to rely on a programmer when they find they need a keyword that doesn't exist.

The main point of the package is to allow people to write well factored, very readable, yet maintainable and powerful Robot tests. Whether our page objects every get built up enough for non technical folk to actually write their own tests is a bit questionable because as I've said it's likely existing keywords won't usually cut it for new testing needs.
--
Thanks,
-Aaron

Daniel Frishberg

unread,
Dec 8, 2014, 10:31:49 AM12/8/14
to robotframe...@googlegroups.com
Thank you for your interest! We actually have methods "find_element" and "find_elements" (https://github.com/ncbi/robotframework-pageobjects - see "Using WebElements" in the readme) that you can use in your classes that extend "Page", though these methods are currently not exposed as keywords. Can you provide an example test where you would want to use these keywords?

Aaron Cohen

unread,
Dec 8, 2014, 10:39:05 AM12/8/14
to robotframe...@googlegroups.com
Daniel, I'd think that you'd not want to expose those as keywords. The whole point of this package is for tests to be at a higher level then finding elements on a page. That kind of business you want to keep out of tests and push into the page objects themselves.

Gu Ru

unread,
Dec 8, 2014, 10:42:20 AM12/8/14
to robotframe...@googlegroups.com
Thank you Aaron and Daniel for information on non_keywords and find_element(s)

Aaron Cohen

unread,
Dec 8, 2014, 2:27:07 PM12/8/14
to robotframe...@googlegroups.com
To clarify, use find_element(s) in your page objects. They are wrappers for SE2's element_find. But we didn't intend find_element(s) to be used as keywords.

Aaron Cohen

unread,
Feb 10, 2015, 9:05:50 AM2/10/15
to robotframe...@googlegroups.com
An update on how this is being used at our organization...

We've found some resistance to it in that folks don't necessarily want all that abstraction, at least up-front. Luckilly the framework is abstract enough to allow iterative abstraction. What I mean by that is that you could write tests with this framework and still gain a lot of benefits, but without full page object modeling. You can start off slow, then factor out more and more into the page object if and when necessary. I've clarified this a bit more in the README:
https://github.com/ncbi/robotframework-pageobjects

The take away here is that organizations that are resistant to BDD and page object modeling will be able to swallow it all a bit more easily if they know they can get their feet wet first without too much up-front commitment. Worst case is that you're using a library that makes even procedural SE code more convenient.

Bryan Oakley

unread,
Feb 10, 2015, 2:41:29 PM2/10/15
to Aaron Cohen, robotframework-users
I just took the new page object library for a spin. I'm very impressed. 

My main concern with the first version was whether libdoc could generate useful documentation. Nice to see that it can, though I wish there were a way to separate the common keywords from the page-specific keywords. The problem is, for a tool like robotframework-hub that presents a list of all known keywords, "close" and "log" and "go to" and so on appear once for every single page object. 20 pages? 20 instances of "close". Yuck. Though, maybe I can add some special cases in robotframework-hub specifically for this library. 

I really like how easy this makes it to write low level functionality in python. Some things (like looping and complex logic) is really cumbersome using robot keywords. 

I think showing this to my team might make them very sad, because this might cause them to throw away a couple months worth of work. This way of doing page objects seems like it might be much better that what they've tried with resource files. 

Thank you for making this available. 


--

Bryan Oakley

unread,
Feb 10, 2015, 5:37:17 PM2/10/15
to Aaron Cohen, robotframework-users
Would it be possible to add a configuration parameter somewhere that causes all of the built-in methods on a page ("Go To", "Get Hash", etc) to _not_ be included in the output created by libdoc? That would make the page objects library play much more nicely with robotframework-hub -- you don't end up with dozens of identical keywords in the master keyword list. 

Since you're already relying on special environment variables, maybe a "PO_LIBDOC_MODE" variable with a value of "standard" to get the current behavior, or "truncated" (or "terse", or ...?) to give the shortened list of keywords? Too bad libdoc doesn't have a way to pass variables on the command line :-\

It would also be nice if I could replace the hard-coded link you add to the Selenium2Library documentation, since robotframework-hub hosts that documentation locally. Maybe you could make the paragraph that is appended to the Page documentation configurable -- maybe an attribute on the Page class itself? (eg: Before calling libdoc perhaps I could do "Page.__extradoc__= 'yada yada yada <link to selenium2library> yada yada <link to Page library> yada yada'")





On Tue, Feb 10, 2015 at 8:05 AM, Aaron Cohen <kahun...@gmail.com> wrote:

--

Jared Hellman

unread,
Feb 10, 2015, 6:35:37 PM2/10/15
to robotframe...@googlegroups.com, kahun...@gmail.com
Aren't you mainly going to be looking at the libdocs in the context of writing tests though and you'd want to see all of the keywords which are available in the Page Object you're working on?  Yes, it's repetitive to have the common keywords in each Page doc, but only if you're skimming through all your Page docs at once which should be somewhat rare.  

What I would love to do is separate the common keywords into a separated category at the bottom of each doc, but I'm not sure how to get that done.  Any suggestions?

I wasn't aware of robotframework-hub, looks very neat, I'll have to play with it soon :)
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Bryan Oakley

unread,
Feb 10, 2015, 7:21:10 PM2/10/15
to jhel...@gmail.com, robotframe...@googlegroups.com, kahun...@gmail.com
A test may span more than one page, so it's highly likely to see the same keyword more than once. Plus, the hub lets you search all keywords in your system (and eventually, just all keywords visible in the current suite). I think the best option is to only show the common keywords on the documentation for "Page', and link to them like you link to selenium keywords. 

I put in a quick hack to my development copy of the hub, and It's really cool to see all my keywords organized into pages. I hacked in code to strip out the common functions, and the user experience is definitely better. 

--bryan

To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Mykhailo Poliarush

unread,
Feb 11, 2015, 2:02:06 AM2/11/15
to robotframe...@googlegroups.com

Aaron Cohen

unread,
May 12, 2015, 11:56:27 AM5/12/15
to robotframe...@googlegroups.com
Our organization as found that we need different levels of abstraction. That is to say sometimes full page object modeling is necessary, but sometimes that's over optimization depending on the project. Over optimization has many well-known disadvantages, but on top of it all if you require too much page modeling up front, it discourages your organization from ever adopting the page object model at all. We updated robotframework-pageobjects to allow easy, simple cases, such as simply opening up a browser and using the base Page object without a url attribute. This makes it so that you don't have to subclass if you don't want. We updated the docs (README)  to reflect this, especially under the  "Some Examples" section. To get the updates you'll have to pip install --update.
https://github.com/ncbi/robotframework-pageobjects

Zephyr Raphael

unread,
May 18, 2015, 7:28:02 PM5/18/15
to robotframe...@googlegroups.com
This looks pretty neat, I'm glad the community is continuing to evolve. 

With that being said, if there's anything that you see in the Selenium2Library which could improve its usability let us know by opening an issue on github.
Reply all
Reply to author
Forward
0 new messages