vbscripthp-uftuft14

UFT/QTP dynamical url


i have this problem, an "url" has a "token" which generates a random number. When i try to manipulate an object in this "url" during the run session, UFT doesn't recognize the object because the "url" change.

For example:

record::

Browser("url").Page("dynamicalUrl").WebButton("cancel").Click 
'The url value of Page( "dynamicalUrl") is for example: https://example.com/token=542654364678

Run Session::

UFT crashes in the step, because it doesn't recognize objects and the url value of Page( "dynamicalUrl") changes to: https://example.com/token=987757858

Is there any solution to this?, if someone know how to solve this, thanks in advance.


Solution

  • Usually it is a Bad Practice to use the URL as a Page identififer. Try to use the title property instead.

    In case you need the URL, use it as a Regular Expression. If your token is just numbers than the regexp is something like:

    https://example.com/token=\d+
    

    Generally speaking whatever is a dynamic part in a Property you need to use Regular Expressions for that