Forum Discussion

rauny's avatar
rauny
Occasional Contributor
11 years ago
Solved

How to run Keyword tests in different urls.

Hi guys,



I need some advice to adjust my Keyword Tests. I've already recorded my tests, and that worked fine. But, now I need to run the same tests in different Urls.



I've tried creating a variable in the project, and setting the value with that variable.



New Url: "http://localhost:7003/administracao/login/loginPage.xhtml"



After this, I run the test again, the web browser page is open in the new address, but the tests didn't work, because the actions, for example, set text login, saved the previous address for the action:



NameMapping.Sys.Browser().Page("http://localhost:8080/administracao/login/loginPage.xhtml").Panel(0).Panel(0).Panel("idLoginPanel").Panel(1).Panel("contentLogin").Form("form_login").Panel(0).Textbox("j_username")



I need to change one by one? I've tried changing to (Url) but that didn't work too.



NameMapping.Sys.Browser().Page(Url).Panel(0).Panel(0).Panel("idLoginPanel").Panel(1).Panel("contentLogin").Form("form_login").Panel(0).Textbox("j_username")



Can you guys help me?



Thanks.



  • Without using namemapping, it's a bit trickier.  You most likely will not be able to retain your recorded steps.  You may need to re-construct your keyword test.  Basically, you'd need to do something like



    1. Use the Call Object Method test action to call the ToURL method on the Sys.Browser() object, passing in the URL variable to the method.


    2. Add in your On Screen actions manually... when prompted for the page object (NameMapping.Sys.Browser().Page()) enter an asterisk (*) for the page URL.  This will take whatever page you have up.


    Honestly, it's a LOT easier if you at least map your page and then set the URL value on your page to be your project variable for the URL.



    Now, based upon your original post, it LOOKS like all you are changing in the URL is the port number.  In which case, step 1 above may be all that is necessary to open up your initial URL.   Then you can double click on each action and just replace the port number in your action with the asterisk.



    Hope this helps.

4 Replies

  • rauny's avatar
    rauny
    Occasional Contributor
    Hi Robert,



    I've changed to use * in the Sys.Browser().Page("*") and this solved my problem.



    Now, all I have to do to run in differents urls is change the variable Url in the project (one time).



    I've used * because my urls will change the port number and the address too.



    Thank you so much! :)



  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Since you have a project variable already set up for your URL, you've made it easy on yourself.  



    What you'll need to do is go into your NameMapping, find the Page object (assuming it's mapped since you are using NameMapping in your example), and edit the URL property.  Set the property to be a "Project Variable" and select your URL variable.



    Let me know if this helps.  Screenshot attached
  • rauny's avatar
    rauny
    Occasional Contributor
    Hi Robert,



    I'm sorry but I'm not using mapping objects. I've unchecked the options, image attached.



    I've tried changing to use the variable Url, and the browser opens in the new Url, but in the event set text it didn't work, because the event was saved with the previous Url.



    Is there a way to change all the urls in the project without using mapping objects?
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Without using namemapping, it's a bit trickier.  You most likely will not be able to retain your recorded steps.  You may need to re-construct your keyword test.  Basically, you'd need to do something like



    1. Use the Call Object Method test action to call the ToURL method on the Sys.Browser() object, passing in the URL variable to the method.


    2. Add in your On Screen actions manually... when prompted for the page object (NameMapping.Sys.Browser().Page()) enter an asterisk (*) for the page URL.  This will take whatever page you have up.


    Honestly, it's a LOT easier if you at least map your page and then set the URL value on your page to be your project variable for the URL.



    Now, based upon your original post, it LOOKS like all you are changing in the URL is the port number.  In which case, step 1 above may be all that is necessary to open up your initial URL.   Then you can double click on each action and just replace the port number in your action with the asterisk.



    Hope this helps.