Forum Discussion

michael_2's avatar
11 years ago

Changing website urls for tests

I have a simple test build that goes to one of our websites and clicks a link.  It works when I execute it on that website A - the website it was originally recorded on. 



However, when I execute the same test on website B, which is an identical copy of website A with a different url - I get errors. 



I'm using Keyword tests, and I have a variable defined for the value.  When the variable's set to website A's url - it executes normally; on website B it generates errors.



The errors for each step are the same

'An error occurred while accessing the "XXX" method or property of the "XXX" object.


The object or one of its parent objects was not found.



Object Whose Method or Property Was Accessed'






When I convert to script, I don't see anything hard-coded that looks like it would cause an error.



function Test10()

{

  var StartUrl;

  StartUrl = "http://XXX.website.com";

  //Opens the specified URL in a running instance of the specified browser.

  Browsers.Item(btIExplorer).Navigate(StartUrl);

  //Waits until the browser loads the page and is ready to accept user input.

  Aliases.browser.someMethod.Wait();

  //Moves the mouse pointer over the 'linkHomeAspx' control.

  Aliases.browser.someMethod.formAspnetform.panelSmoothmenuAjax.linkHomeAspx.HoverMouse(0, 0);

  //Moves the mouse pointer over the 'panelLeftnavbrowseUpdatepanel1' control.

  Aliases.browser.someMethod.formAspnetform.panelLeftnavbrowseUpdatepanel1.HoverMouse(187, 30);

  //Clicks at point (3, 11) of the 'panelHitareaExpandableHitarea' object.

  Aliases.browser.someMethod.formAspnetform.panelLeftnavbrowseUpdatepanel1.panelHitareaExpandableHitarea.Click(3, 11);

  Aliases.browser.someMethod.Wait();

}



2 Replies

  • Where you do have the parameter defined?



    I use scripts, rather than keyword, tests but I use a base level URL parameter all the time without problems. It needs to be in place anywhere the test makes use of the URL. So that's navigation events (as you have in the script you posted) but also any object identification properties. You have aliases in there. How are they being identified? If they're using the URL, you need you parameter in the object identification properties as well.
  • I'd second the namemapping idea. You have aliases in play and if you didn't change the name mapping after recording your keyword test, it most likely added the URL as a property of the page. If that happened, it wouldn't ever recognize the 2nd environment because the URL of the page it launched doesn't match. You'll want to open the NameMapping file and see what it has for the properties of "someMethod" (based on your script). If it has the URL, open it and put an asterisk in place of the X's in your startURL.