From 99d69b97fcac79614674fafe5b250fda40d97d79 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:06:21 -0400 Subject: [PATCH 01/15] Copied README --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2a7d107..ec19596 100755 --- a/README.md +++ b/README.md @@ -30,7 +30,39 @@ Like we said, the package is very flexible: it doesn't force you to use Robot, n to do heavy page object modeling up front. This is great for convicing your organization to move toward BDD and page object development because you can approach those ideals iteratively. Even with light modeling, and use of a non-BDD framework, your test suites -can still benefit from the above listed features. Here's an example of a very minimally +can still benefit from the above listed features. + +## Some Examples +Here's an example of about the simplest Robot test case you could write using this package. You don't even have +to model a page object...you could just write a test using the base `Page` class that comes with this package:: + + *** Settings *** + Library robotpageobjects.Page + + *** Test Cases *** + Can Open Google + Open + Location Should Be http://www.google.com/ + Close + + +To run it:: + + $ pybot -vbaseurl:http://www.google.com test.robot + ============================================================================== + Test + ============================================================================== + Can Open Google | PASS | + ------------------------------------------------------------------------------ + Test | PASS | + 1 critical test, 1 passed, 0 failed + 1 test total, 1 passed, 0 failed + ============================================================================== + +Now in Python: + + +Here's an example of a very minimally abstracted page object, where we're using a few page object assertions (`title_should_be`, `element_should_be_visible`). # mytest.py @@ -61,7 +93,7 @@ abstracted page object, where we're using a few page object assertions (`title_s We could run this test on a local Firefox installation like so (you could, of course, -persist these settings using your `.bash_profile` file: +persist these settings using your `.bash_profile` file): $ export PO_BASEURL=http://qa.mydomain.com $ export PO_BROWSER=firefox @@ -779,6 +811,19 @@ which follows the example of Robot assertions and makes it obvious that the meth Page object assertion methods shouldn't change the state of the page (eg. clicking links, navigating back etc.) and minimal computation, looping etc. State change and computation should be done in page object action/helper methods. In your test, you should get the page to the state where you want it to be using other page object methods, and call the assert method. +## Sauce Labs Cloud Testing Service Integration + +robotframework-pageobjects integrates seamlessly with +[Sauce Labs](http://saucelabs.com/), a cloud service allowing you to run Selenium-based +jobs on a [multitude of browsers and platforms](https://docs.saucelabs.com/reference/platforms-configurator/#/). +Simply set at least the `sauce_apikey`, `sauce_username`, `sauce_platform` and the `browser` +built-in IFT options. See the Built-in options section [above](#built-in-options-for-page) for options +related to running tests in Sauce. + +Your page objects will automatically tag your Robot Sauce jobs with their +associated test names and +test status. + ## Logging Reporting & Debugging ### Robot From e7cf01286d04a58200c829d8c65f9a8cbee0a4fb Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:07:40 -0400 Subject: [PATCH 02/15] Added python example --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ec19596..c1f0a09 100755 --- a/README.md +++ b/README.md @@ -59,7 +59,21 @@ To run it:: 1 test total, 1 passed, 0 failed ============================================================================== -Now in Python: +Now in Python:: + + import unittest + from robotpageobjects import Page + + + class MyTestCase(unittest.TestCase): + def test_can_open_google(self): + p = Page() + p.open() + p.location_should_be("http://www.google.com/") + p.close() + + if __name__ == "__main__": + unittest.main() Here's an example of a very minimally From 13ab33903737772482f5199148b5b50e31fc46c1 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:09:14 -0400 Subject: [PATCH 03/15] Added python run --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index c1f0a09..0e38835 100755 --- a/README.md +++ b/README.md @@ -75,6 +75,15 @@ Now in Python:: if __name__ == "__main__": unittest.main() +To run: + + $ export PO_BASEURL=http://www.google.com + $ python test.py + . + ---------------------------------------------------------------------- + Ran 1 test in 1.411s + + OK Here's an example of a very minimally abstracted page object, where we're using a few page object assertions (`title_should_be`, `element_should_be_visible`). From 22dc906e5f0ae0ab210c6297a276ddf423eb67df Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:13:13 -0400 Subject: [PATCH 04/15] More change sto rEADME --- README.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e38835..0655e16 100755 --- a/README.md +++ b/README.md @@ -59,7 +59,12 @@ To run it:: 1 test total, 1 passed, 0 failed ============================================================================== -Now in Python:: +By default, the test runs in PhantomJS, but you could run it in Firefox (if it's set up locally) +like this:: + + $ pybot -vbaseurl:http://www.google.com -vbrowser:firefox test.robot + +Now the same test in Python:: import unittest from robotpageobjects import Page @@ -75,7 +80,7 @@ Now in Python:: if __name__ == "__main__": unittest.main() -To run: +To run, set the baseurl option with an environment variable: $ export PO_BASEURL=http://www.google.com $ python test.py @@ -85,6 +90,11 @@ To run: OK +To run with Firefox, you'd have to set the `browser` environment variable:: + + $ export PO_BROWSER=firefox + $ python test.py + Here's an example of a very minimally abstracted page object, where we're using a few page object assertions (`title_should_be`, `element_should_be_visible`). From 94254b9afbc2f0bcbf1d7543d4ee0fa44fb672ac Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:14:03 -0400 Subject: [PATCH 05/15] Took out extra colons --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0655e16..e577f54 100755 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ can still benefit from the above listed features. ## Some Examples Here's an example of about the simplest Robot test case you could write using this package. You don't even have -to model a page object...you could just write a test using the base `Page` class that comes with this package:: +to model a page object...you could just write a test using the base `Page` class that comes with this package: *** Settings *** Library robotpageobjects.Page @@ -46,7 +46,7 @@ to model a page object...you could just write a test using the base `Page` class Close -To run it:: +To run it: $ pybot -vbaseurl:http://www.google.com test.robot ============================================================================== @@ -60,11 +60,11 @@ To run it:: ============================================================================== By default, the test runs in PhantomJS, but you could run it in Firefox (if it's set up locally) -like this:: +like this: $ pybot -vbaseurl:http://www.google.com -vbrowser:firefox test.robot -Now the same test in Python:: +Now the same test in Python: import unittest from robotpageobjects import Page From dfec5df28698aaa847ab628fcb4ccd0d683e2576 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:16:06 -0400 Subject: [PATCH 06/15] More edits to README --- README.md | 44 +------------------------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/README.md b/README.md index e577f54..2d337b3 100755 --- a/README.md +++ b/README.md @@ -90,53 +90,11 @@ To run, set the baseurl option with an environment variable: OK -To run with Firefox, you'd have to set the `browser` environment variable:: +To run with Firefox, you'd have to set the `browser` environment variable: $ export PO_BROWSER=firefox $ python test.py -Here's an example of a very minimally -abstracted page object, where we're using a few page object assertions (`title_should_be`, `element_should_be_visible`). - - # mytest.py - from robotpageobjects import Page - import unittest - - class MyPage(Page): - uri = "/some/path" - selectors = { - "the portlet": "xpath://some/complicated/xpath" - } - - class MyTestCase(unittest.TestCase): - def setUp(self): - self.page = Page() - self.page.open() - - def tearDown(self): - self.page.close() - - def test_title(self): - self.page.title_should_be("My Page") - - def test_portlet_renders(self): - self.page.element_should_be_visible("the portlet") - - unittest.main() - - -We could run this test on a local Firefox installation like so (you could, of course, -persist these settings using your `.bash_profile` file): - - $ export PO_BASEURL=http://qa.mydomain.com - $ export PO_BROWSER=firefox - $ export PO_SELENIUM_SPEED=1 # Slow the whole test down for debugging - $ python mytest.py - -Notice, we did not factor out all page implementation details from the test itself. But -we still can leverage many of the package's features in our tests. If we need to model the page -further, nothing stops us from doing so in the future. -We'll learn how to do this in a bit. ## More on page objects The main point of using page objects is to factor out page implementation details (element 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. From b44bdf50c9e2493958dfee75a2932603d81653b1 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:21:51 -0400 Subject: [PATCH 07/15] More edits --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2d337b3..4c36a8c 100755 --- a/README.md +++ b/README.md @@ -33,8 +33,12 @@ with light modeling, and use of a non-BDD framework, your test suites can still benefit from the above listed features. ## Some Examples -Here's an example of about the simplest Robot test case you could write using this package. You don't even have -to model a page object...you could just write a test using the base `Page` class that comes with this package: +Here's some examples of about the simplest Robot test case you could write using this package. You don't even have +to model a page object...you could just write a test using the base `Page` class that comes with this package yet by +using this package you get some things for free, like the ability to: +- pass in test options such as `baseurl`, `browser` etc. to both Robot tests and Python tests (see [Setting Options](#setting-options) for more +built-in options you can use) +- use of Selenium2Library keywords/methods in both Robot and Python tests *** Settings *** Library robotpageobjects.Page From d3ff980b689e36a7fd31eb8067c320af585e0eb7 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:25:30 -0400 Subject: [PATCH 08/15] edits --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4c36a8c..6944e0f 100755 --- a/README.md +++ b/README.md @@ -34,12 +34,15 @@ can still benefit from the above listed features. ## Some Examples Here's some examples of about the simplest Robot test case you could write using this package. You don't even have -to model a page object...you could just write a test using the base `Page` class that comes with this package yet by -using this package you get some things for free, like the ability to: +to model a page object...you could just write a test using the base `Page` class that comes with this package, yet by +simply using the base `Page` object that comes with this package you get some things for free, like the ability to: + - pass in test options such as `baseurl`, `browser` etc. to both Robot tests and Python tests (see [Setting Options](#setting-options) for more built-in options you can use) - use of Selenium2Library keywords/methods in both Robot and Python tests +This is a very simple Robot test using `Page`: + *** Settings *** Library robotpageobjects.Page From 748b42dceed087911d317513bb30667458dc4f95 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:26:44 -0400 Subject: [PATCH 09/15] edits --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6944e0f..50dcbd4 100755 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ can still benefit from the above listed features. ## Some Examples Here's some examples of about the simplest Robot test case you could write using this package. You don't even have to model a page object...you could just write a test using the base `Page` class that comes with this package, yet by -simply using the base `Page` object that comes with this package you get some things for free, like the ability to: +simply using `Page` you get some things for free, like the ability to: - pass in test options such as `baseurl`, `browser` etc. to both Robot tests and Python tests (see [Setting Options](#setting-options) for more built-in options you can use) From 58d82dc96bd5a576f6f78715730c3cd9af97e11c Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:27:49 -0400 Subject: [PATCH 10/15] edits --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 50dcbd4..21a4bbb 100755 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ To run, set the baseurl option with an environment variable: OK -To run with Firefox, you'd have to set the `browser` environment variable: +To run with Firefox, use the `PO_BROWSER` environment variable: $ export PO_BROWSER=firefox $ python test.py From 54ee18a7c834efabd58ab57edbde5e92bfb38770 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:30:51 -0400 Subject: [PATCH 11/15] README edits --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 21a4bbb..88ac444 100755 --- a/README.md +++ b/README.md @@ -104,7 +104,8 @@ To run with Firefox, use the `PO_BROWSER` environment variable: ## More on page objects -The main point of using page objects is to factor out page implementation details (element 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. +Though you could write very simple tests using this package, it allows you to heavily model your applications-under-test using +your own subclasses of `Page`. You can factor out page implementation details (element 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. ## How it works Each page object you create is simply an object that inherits from this package's base `Page` class. In the context of a Robot test, the object is a Robot library. Since these classes are *plain old Python classes* they can work independently of Robot @@ -112,7 +113,7 @@ Framework, even though they ultimately inherit their base methods from Robot Fra ## Demo -Check out and run the [demo](https://github.com/ncbi/robotframework-pageobjects/tree/master/demo). +To see some more complex page objects, Check out and run the [demo](https://github.com/ncbi/robotframework-pageobjects/tree/master/demo). ## How the demo works From 4ccca5d6333bc30d589e45130c2ee07e454511e0 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:34:17 -0400 Subject: [PATCH 12/15] README edits --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 88ac444..cb1e8c7 100755 --- a/README.md +++ b/README.md @@ -109,7 +109,10 @@ your own subclasses of `Page`. You can factor out page implementation details (e ## How it works Each page object you create is simply an object that inherits from this package's base `Page` class. In the context of a Robot test, the object is a Robot library. Since these classes are *plain old Python classes* they can work independently of Robot -Framework, even though they ultimately inherit their base methods from Robot Framework's Selenium2Library. This allows you to encapsulate page logic in Robot libraries, but still leverage those classes in any testing framework. +Framework, even though they ultimately inherit their base methods from Robot Framework's Selenium2Library. This allows you to encapsulate page logic in Robot libraries, but still leverage those classes in any testing framework if need be. Thus the brunt +of your coding can go in the page objects, not the test suites. Your tests become more declarative, deferring the work +to the page objects. Since the page objects are written in Python you are less tied to a particular testing framework, though of +course we are partial to Robot! ## Demo From af1b7ee8a771815111500b25d6c1a7ac498cbee4 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:37:04 -0400 Subject: [PATCH 13/15] Formatting --- demo/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/demo/README.md b/demo/README.md index c6ae591..ba94ae0 100755 --- a/demo/README.md +++ b/demo/README.md @@ -2,19 +2,19 @@ Demo ==== This directory contains a demo of the Robot Page Objects package. It demonstrates how you can write a -suprememly readable Robot test leveraging Selenium2Library to create page object libraries, which are usable + readable Robot test leveraging Selenium2Library to create page object libraries, which are usable in Robot and outside of Robot. How to run the demo -------------------- 1. Create a virtual environment, then -1. pip install robotframeworkpageobjects -2. $ pybot -vbrowser:firefox -vbaseurl:http://www.ncbi.nlm.nih.gov test_pubmed.txt +1. `pip install robotframework-pageobjects` +1. `$ pybot -vbrowser:firefox -vbaseurl:http://www.ncbi.nlm.nih.gov test_pubmed.txt` To run the Python unittest example: -$ export PO_BASEURL=http://www.ncbi.nlm.nih.gov -$ export PO_BROWSER=firefox -$ python test_pubmed.py +1. `$ export PO_BASEURL=http://www.ncbi.nlm.nih.gov` +1. `$ export PO_BROWSER=firefox` +1. `$ python test_pubmed.py` By default tests will run in PhantomJS unless you specify otherwise. From 2a92e17613a3cf9490903049f5c931177239f4af Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:37:53 -0400 Subject: [PATCH 14/15] readmechanges --- demo/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/demo/README.md b/demo/README.md index ba94ae0..41ca205 100755 --- a/demo/README.md +++ b/demo/README.md @@ -13,6 +13,7 @@ How to run the demo 1. `$ pybot -vbrowser:firefox -vbaseurl:http://www.ncbi.nlm.nih.gov test_pubmed.txt` To run the Python unittest example: + 1. `$ export PO_BASEURL=http://www.ncbi.nlm.nih.gov` 1. `$ export PO_BROWSER=firefox` 1. `$ python test_pubmed.py` From 509266b3aae1e4426f2a4ede5d68bb5d3e0e24b9 Mon Sep 17 00:00:00 2001 From: cohenaa Date: Mon, 11 May 2015 11:41:15 -0400 Subject: [PATCH 15/15] Added more --- demo/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/README.md b/demo/README.md index 41ca205..b140c43 100755 --- a/demo/README.md +++ b/demo/README.md @@ -8,6 +8,7 @@ in Robot and outside of Robot. How to run the demo -------------------- +1. Ensure you have phantomjs installed properly on your system. 1. Create a virtual environment, then 1. `pip install robotframework-pageobjects` 1. `$ pybot -vbrowser:firefox -vbaseurl:http://www.ncbi.nlm.nih.gov test_pubmed.txt` @@ -15,7 +16,6 @@ How to run the demo To run the Python unittest example: 1. `$ export PO_BASEURL=http://www.ncbi.nlm.nih.gov` -1. `$ export PO_BROWSER=firefox` 1. `$ python test_pubmed.py` -By default tests will run in PhantomJS unless you specify otherwise. +By default tests will run in PhantomJS unless you specify otherwise. See the rest of the main README for more features.