Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ There are two types of page objects: singular and templated.

### Singular Page Objects

A singular page object models a page with only one URL. For example, `GoogleHomePage` is singular, because there's only one URI: “/“. Singular page objects should have a `uri` attribute in their class definitions:
A singular page object models a page with only one URL. For example, `GoogleHomePage` is singular, because there's only one URI: “/“. Singular page objects should have a `uri` attribute (defaults to '/') in their class definitions:

...
class MyAppHomePage(EntrezPage):
Expand Down
3 changes: 3 additions & 0 deletions robotpageobjects/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def __init__(self):
# Allow setting of uri_template or uri, but make them the same internally
if hasattr(self, 'uri_template'):
self.uri = self.uri_template
# Set a default uri in case one is not set in the Page
elif not hasattr(self, 'uri'):
self.uri = '/'

@staticmethod
@not_keyword
Expand Down
7 changes: 7 additions & 0 deletions tests/scenarios/test_go_to.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import unittest
from po import widget_template
from robotpageobjects import Page


class TestWidgetItem(unittest.TestCase):
Expand All @@ -10,6 +11,12 @@ def test_widget_item(self):
self.widget_item_page.go_to({"category": "home-and-garden", "id": "123"})
self.widget_item_page.title_should_be("Cool Widget")

def test_no_uri_template(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this scenario being used? I don't see a test for it in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's run when its parent TestCase is run which is already happening.

self.p = Page()
self.p.baseurl = 'https://www.google.com/'
self.p.open()
self.p.title_should_be('Google')

def tearDown(self):
try:
self.widget_item_page.close()
Expand Down
4 changes: 0 additions & 4 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ def test_no_baseurl_gives_readable_error_in_robot(self):
run = self.run_scenario("test_template_passed.robot")
self.assert_run(run, expected_returncode=1, search_output="must set a baseurl")

def test_no_uri_attr_gives_readable_error_in_robot(self):
run = self.run_scenario("test_no_uri.robot", variable="baseurl:%s" % self.base_file_url)
self.assert_run(run, expected_returncode=1, search_output='must have a "uri" attribute set')

def test_enlarge_browser_on_open(self):
self.set_baseurl_env()
run = self.run_scenario("test_enlarge_browser_on_open.py")
Expand Down
13 changes: 6 additions & 7 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,6 @@ def test_no_baseurl_set_and_uri_attr_set_and_uri_vars_set(self):
self.PO.uri = "/foo"
self.PO()._resolve_url("bar")

@raises(exceptions.UriResolutionError)
def test_baseurl_set_no_uri_attr_set(self):
"""A baseurl is set, but no variables were passed in and no "uri" was set."""

self.set_baseurl_env()
self.PO()._resolve_url()

@raises(exceptions.UriResolutionError)
def test_baseurl_set_abs_uri_attr(self):
"""An absolute url (with scheme) was set as the uri."""
Expand Down Expand Up @@ -340,6 +333,12 @@ def test_uri_template_is_resolved(self):
self.assertEquals("123", pid)
self.assertEquals("http://www.ncbi.nlm.nih.gov/pubmed/123", url)

def test_baseurl_set_no_uri_attr_set(self):
"""A baseurl is set, but no variables were passed in and no "uri" was set."""

self.set_baseurl_env()
self.PO()._resolve_url()


class SelectorsTestCase(BaseTestCase):
@raises(exceptions.DuplicateKeyError)
Expand Down