Using Page.open with parameters, and a default URL that contains more than an authority

1,742 views
Skip to first unread message

Mike W

unread,
Feb 23, 2013, 11:07:36 PM2/23/13
to thucydid...@googlegroups.com
I'm wondering if I'm doing something wrong here.

I have a page with the following:
@NamedUrls({
        @NamedUrl(name = "updateContactDetails", url = "/contacts/update/{1}")
})

When I run my tests, I'm defining webdriver.base.url=http://localhost:18080/contactmanager.

In my steps, I'm using getPages().get(mypage.class).open("updateContactDetails", 339) but instead of having http://localhost:18080/contactmanager/contacts/update/339, I end up with http://localhost:18080/contactmanager/contactmanager/contacts/update/339.

First, am I doing something wrong here? Have I misunderstood something about how these parts are supposed to work, or would you expect this to work correctly?

If what I've done is correct, then based on stepping through the code, the issue appears to be in PageUrls.updatedFullUrl. It replaces the url authority with the defined base url which of course strps http://localhost:8080 from the front, but adds http://localhost:18080/contactmanager to the front.

If this is a bug, let me know, and I'll create a JIRA ticket. Time permitting, I'll even try to correct it.

John Smart

unread,
Feb 24, 2013, 12:17:24 AM2/24/13
to thucydid...@googlegroups.com
Hi Mike,

The duplication of 'contactmanager' in the URL looks kinda like a bug to me - raise a JIRA and I'll take a look.

Cheers,

John.

John Smart

unread,
Feb 24, 2013, 5:28:53 AM2/24/13
to thucydid...@googlegroups.com
Hi Mike,

I added a unit test for this case, but couldn't reproduce the problem. Could you post the exact code that is causing the problem?
(By the way, you don't need to initialize your page objects anymore, you can just declare a variable of a type that inherits from PageObject, and Thucydides will instanciate it for you - you still need to call open(), though).

Cheers,

John.

Mike W

unread,
Feb 24, 2013, 1:57:36 PM2/24/13
to thucydid...@googlegroups.com
Thank you for the speedy reply. I'll try and extract a minimal example that exhibits the issue I'm seeing.

By the way, when was field initialization of pageObject's introduced? Don't recall seeing it in release notes, but it's been hard to keep up ;) Do I just define a field in my Steps class, and it will get initialized, or do I need to annotate it?

Mike W

unread,
Feb 24, 2013, 2:54:22 PM2/24/13
to thucydid...@googlegroups.com
I have created ticket Thucydides-142 and added a test case that shows the issue I'm experiencing. Please let me know if you need additional details. 

John Smart

unread,
Feb 24, 2013, 4:24:46 PM2/24/13
to thucydid...@googlegroups.com
Thanks. The quick fix would be to set the base URL to "http://localhost:18080". Thucydides replaces the host and port part of the URL with the base, but doesn't really know how to merge a base url containing a path. Easy enough to add a patch that caters for this duplication, but this opens a more interesting general question. What would the expected behaviour be if you wanted the base URL to be "http://localhost:18080/contactmanager-uat", for example? Or "http://localhost:18080/uat/contactmanager"? What conventions could it use to know how to merge non-trival base URLs? I'd be interested to hear peoples thoughts on this.

Mike W

unread,
Feb 24, 2013, 9:19:33 PM2/24/13
to thucydid...@googlegroups.com
I've taken your suggestion and shortened by default url so it only has the authority section. I'll have to do some experimentation and thinking to determine what I'd really like to see, and then we can discuss further.

And obviously, if others have opinions, please join in...
Reply all
Reply to author
Forward
0 new messages