-
Notifications
You must be signed in to change notification settings - Fork 73
Qar 49187 demo #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9c723c4
QAR-49187: Corrected README.
2cb5dc1
Renamed modules
0f5ad64
Added pubmed.py
73cc48b
QAR-49187: Got python test working
0c3e266
QAR-49187: demos working
733091b
Deleted old google page
9f7dcec
Modified README
434bf70
Added a little more text to README.
24bcfb8
Changed titles of tests
24e95f1
Corrected uri_template
ba06180
Updated README
b690a1b
Corrected
d58e745
More corrections
4c2ac39
Adding more corrections
60bedb8
Corrections
56524a8
Changed .robot to .txt.
07b6e21
Annoated the pubmed page objects with comments.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| from robotpageobjects import Page, robot_alias | ||
| from robot.utils import asserts | ||
|
|
||
|
|
||
| class PubmedHomePage(Page): | ||
| """ Models the Pubmed home page at: | ||
| HOST://ncbi.nlm.nih.gov/pubmed""" | ||
|
|
||
|
|
||
| # Allows us to call this page | ||
| # something other than the default "Pubmed Home Page" | ||
| # at the end of keywords. | ||
| name = "Pubmed" | ||
|
|
||
| # This page is found at baseurl + "/pubmed" | ||
| uri = "/pubmed" | ||
|
|
||
| # inheritable dictionary mapping human-readable names | ||
| # to Selenium2Library locators. You can then pass in the | ||
| # keys to Selenium2Library actions instead of the locator | ||
| # strings. | ||
| selectors = { | ||
| "search input": "id=term", | ||
| "search button": "id=search", | ||
| } | ||
|
|
||
|
|
||
| # Use robot_alias and the "__name__" token to customize | ||
| # where to insert the optional page object name | ||
| # when calling this keyword. Without the "__name__" | ||
| # token this method would map to either "Type In Search Box", | ||
| # or "Type In Search Box Pubmed". Using "__name__" we can call | ||
| # "Type in Pubmed Search Box foo". | ||
| @robot_alias("type_in__name__search_box") | ||
| def type_in_search_box(self, txt): | ||
| self.input_text("search input", txt) | ||
|
|
||
| # We always return something from a page object, | ||
| # even if it's the same page object instance we are | ||
| # currently on. | ||
| return self | ||
|
|
||
| @robot_alias("click__name__search_button") | ||
| def click_search_button(self): | ||
| self.click_button("search button") | ||
|
|
||
| # When navigating to another type of page, return | ||
| # the appropriate page object. | ||
| return PubmedDocsumPage() | ||
|
|
||
| @robot_alias("search__name__for") | ||
| def search_for(self, term): | ||
| self.type_in_search_box(term) | ||
| return self.click_search_button() | ||
|
|
||
|
|
||
| class PubmedDocsumPage(Page): | ||
| """Models a Pubmed search result page. For example: | ||
| http://www.ncbi.nlm.nih.gov/pubmed?term=cat """ | ||
|
|
||
| uri = "/pubmed/?term={term}" | ||
|
|
||
| # This is a "selector template". We are parameterizing the | ||
| # nth result in this xpath. We call this from click_result, below. | ||
| selectors = { | ||
| "nth result link": "xpath=(//div[@class='rslt'])[{n}]/p/a", | ||
| } | ||
|
|
||
| @robot_alias("click_result_on__name__") | ||
| def click_result(self, i): | ||
|
|
||
| # For selector templates, we need to resolve the selector to the | ||
| # locator first, before finding or acting on the element. | ||
| locator = self.resolve_selector("nth result link", n=int(i)) | ||
| self.click_link(locator) | ||
| return PubmedArticlePage() | ||
|
|
||
| class PubmedArticlePage(Page): | ||
|
|
||
| uri = "/pubmed/{article_id}" | ||
|
|
||
| @robot_alias("__name__body_should_contain") | ||
| def body_should_contain(self, str, ignore_case=True): | ||
| ref_str = str.lower() if ignore_case else str | ||
| ref_str = ref_str.encode("utf-8") | ||
| body_txt = self.get_text("css=body").encode("utf-8").lower() | ||
| asserts.assert_true(ref_str in body_txt, "body text does not contain %s" %ref_str) | ||
| return self | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have both "uri" and "uri_template" in this file. I think we made it so that both work, but I would think a demo should be simple and consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catches. Pushed changes as per your comments.