Micro Focus QTP (UFT) Forums
help on replacing the long lines.. - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: help on replacing the long lines.. (/Thread-help-on-replacing-the-long-lines)



help on replacing the long lines.. - lotos - 08-03-2010

Hello. I have a problem with replacing the long lines and reusing the short lines in tests.
I have next approach:
'next line is written within GlobalVariables.qfl file, from where it is called in test scripts:
Code:
Set EnvironmentURL = Browser("URL:=http://test.st").Page("URL:=http://test.st")

In test scripts I am calling it like this, e.g.:
Code:
EnvironmentURL.WebEdit("name:=name_of_textfield").Set "test"

NOW: when I am running the tests what are using such kind of description, the system do not see all the time the 'EnvironmentURL' object. Why can be that?! Maybe the GlobalVariables.qfl should be saved in .vbs extension..
Please Help, it is a very important problem for me now..
Any idea can be very useful.
Thanks a lot!


RE: help on replacing the long lines.. - PrabhatN - 08-03-2010

Hi Lotos,

You can make use of With....End With Statement.

For example,

Code:
With Browser().Page()
.WebEdit().Set ""
.Link().Click
End With



RE: help on replacing the long lines.. - lotos - 08-03-2010

Hi PrabhatN, thanks a lot..
I know that, but I really need the 'EnvironmentURL', because I have more than one, and I will add a comment for the line I don't need - and the object's variable vill be the same, for e.g. I will have:

Code:
Set EnvironmentURL = Browser("URL:=http://test.st").Page("URL:=http://test.st")
'Set EnvironmentURL = Browser("URL:=http://test.at").Page("URL:=http://test.at")
'Set EnvironmentURL = Browser("URL:=http://test.ut").Page("URL:=http://test.ut")

and the used one will be the uncommented line

Also I will be able to call this var in next way:

Code:
With EnvironmentURL
.WebEdit().Set ""
.Link().Click
End With

I will not be able to use Browser().Page() in all my functions and classes, because It will be need of change in a lot of lines, when I will test on another environment than the firstone - from this sample.


RE: help on replacing the long lines.. - lotos - 08-04-2010

The Most important problem is that 'EnvironmentURL' is not all the time visible or found by QTP when the tests are running. Maybe someone had such problems and can help me with that please..


RE: help on replacing the long lines.. - basanth27 - 08-04-2010

Create Objects. Should help.


RE: help on replacing the long lines.. - Niveditha - 08-04-2010

Hi Lotos,

Did you associate the library file to your scripts.
Please do that if not done..
FileMenu--->Settings-->Resources-->Assocaiate function library
I tried your scenario , but I was not able to replicate your issue as I associated the function to my main script.

Please let me know if this doesn't work.

Regards,
Niveditha


RE: help on replacing the long lines.. - lotos - 03-02-2011

Thanks a lot guys, I've used XML, and everything is ok now!


RE: Help on Dynamic URL - Suba - 03-22-2011

Hi,
In continuation to previous thread, I have a question on how to set dynamic address depending on the environment the Test Application will run.

We have multiple environment. How can I run the same test script by using dynamic URL?

Thanks in advance for the help.
Subha


RE: Help on Dynamic URL - basanth27 - 03-23-2011

Subha -
There is no continuation here. Please open a new thread.
This thread is closed.