6

I'd like to know if there is a framework in Python which supports a clean way to define the Page Object Elements on a Page Object.

The site_prism gem does it like so:

class Home < SitePrism::Page
  set_url "/index.htm"
  set_url_matcher /google.com\/?/
  element :search_field, "input[name='q']"
  element :search_button, "button[name='btnK']"
  elements :footer_links, "#footer a"
  section :menu, MenuSection, "#gbx3"
end

class MenuSection < SitePrism::Section
  element :search, "a.search"
  element :images, "a.image-search"
  element :maps, "a.map-search"
end

Does anyone know of a Python package which gives me something similar to site_prism or page_object?

5
  • Our organization has done so for Python. It uses Robot Framework's Selenium2Library under the hood, but is usable independently of Robot tests. I am trying to release it open-source.
    – Aaron
    Aug 1, 2014 at 1:26
  • You ended up writing your own?
    – Jess
    Aug 1, 2014 at 1:31
  • Yes, I didn't find much out there that suited our needs. I think it's a pretty good package and like I said we are trying to get our organization to allow us to release it open-source. It even integrates with Sauce.
    – Aaron
    Aug 1, 2014 at 1:39
  • 1
    I also did quite a lot of research and ended up writing our own. There is not much to it, doing it in Python as compared to Java. You have simpler structure, only what you need. But I am very interested what other people use. Remember, UnitTest was created in Smalltalk not as library module or framework, but just a design pattern. PageObject is design pattern, implement it according to your specific needs. Aug 1, 2014 at 13:26
  • I'm mostly interested in the nice syntax you can get out of it. I found bok-choy and I might look into mimicking the usage when I write my own.
    – Jess
    Aug 1, 2014 at 13:43

5 Answers 5

4

Another option is the page-objects library.

1
  • Nice. It didn't exist when I was looking.
    – Jess
    May 22, 2015 at 14:40
2

You might try WTFramework It seems like a decent starting place for python test infrastructure. I didn't end up using it because my tests ended up using more php and javascript. There are examples of using the page object design pattern.

1
  • That looks reasonable. A lot of it is specific for browser testing. I might learn from their examples and apply them to my mobile-specific POP. Thank you!!
    – Jess
    Sep 21, 2014 at 2:31
1

I ended up writing my own Page Object framework which had some mobile-specific GUI automation features like locators by platform and other nice things so that my tests are platform agnostic.

I'm considering open-sourcing it. Will post here with any updates on that, or if I find another Page Object framework in Python.

1

I believe Robot Framework Page Object Library is the closest one to the description. There is no activity on the said repo now, but that's not because of the usual reasons, the original owners are looking for someone to adopt it. It works pretty well as it is.

The main reason why I like it more than a vanilla Python implementation is that it extends the popular RobotFramework Selenium2Library , and hence you will inherit all of S2L's and RobotFramework's features

-2

I've had great success with holmium.core http://holmiumcore.readthedocs.org/en/latest/

2
  • Welcome to SQA, B.Berndsen. I notice that you have two posts so far, and that they are both promoting holmium core. This isn't entirely against our rules, if you're affiliated with holmium, you will need to disclose this in your post. (Each post that mentions it.) Also, generally a post that is just a link is discouraged. It is sometimes appropriate, but rarely so. A post like this can usually be expanded with examples and supporting information.
    – corsiKa
    Aug 1, 2014 at 2:48
  • Holmium looks pretty good. I think we looked at it, and I don't remember why we didn't choose it. Our solution doesn't expose the driver. That's taken care of in the base Page class. We base our library off of Selenium2Library, which is a really nice Robot interface to Selenium2. This means that you leverage that library whether you are writing Robot tests, unittest TestCases, Cucumber tests etc. It also adds a real page object pattern to Robot, which lacks that ability natively.
    – Aaron
    Aug 1, 2014 at 3:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.