1

For example, if the URL is - http://blah.com?origin=home&id=54&level=2. This could be a dynamically generated link on a webpage with 'id' and 'level' values from the DB.

Now if I want to use this exact URL in my load() or for the assertion in isLoaded() methods of pageobject which extends loadablecomponent, I would need to capture this URL from my page and then pass it to my pageobject. Or worse manually generate this by parsing the URL and getting the query parameters, which is a pain.

Is there a better design or logic to do this easily? Or just remove the driver.get(dynamic URL) from load() and use some other assertions in isLoaded()?

Thanks.

  • If everytime URL generating dynamic then really there is no user of "driver.get(dynamic URL)". How your URL generates , on click on some button? Link? – Helping Hands Jan 29 '15 at 5:26
  • Table with row of objects and their attributes etc. And the main object will have a link that could take the user to pages where one can edit them. The href value would have been generated on the server, would have similar pattern but different values in the query parameters. So the question is how to design the edit pageobject when i need to automate the click event of a main object. – Grasshopper Jan 29 '15 at 6:20
-1

I think your only choices are either clicking the link or creating a variable to hold a parsed url and then passing that variable to driver.get()

I don't know what language you're using but it's super easy to do in Python with the urlparse library.

| improve this answer | |
  • using java. Know libraries which can do it but wanted to avoid parsing option if possible. Better option seems to be storing the URL and passing it to driver.get() as u mentioned. – Grasshopper Jan 29 '15 at 18:41
  • Maybe I'm missing something, but if you're just trying to pass the complete url to driver.get() then why would you need to parse it at all? – AutomaticStatic Jan 29 '15 at 18:42
  • It worked perfectly for URL's without any query parameters. Then I hit upon one with just one query parameter which was easy to parse and just store the value and append to static URL before sending to driver.get() in load(), but it is not a scalable solution as I soon found out. Was wondering if there is a better design to handle instead of passing the URL itself to the pageobject. – Grasshopper Jan 29 '15 at 18:48
  • I'm wondering really what your concern is about parsing the URL, since it's a negligible amount of compute time. If you really want to keep it lean, then parse every url and check for the presence of a query parameter and only rebuild a new URL if it's missing. You could probably even do it with regex if you didn't want to invoke a parsing library. – AutomaticStatic Jan 29 '15 at 18:49

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.