Micro Focus QTP (UFT) Forums
How to use same script for multiple URLs - 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: How to use same script for multiple URLs (/Thread-How-to-use-same-script-for-multiple-URLs)

Pages: 1 2 3


How to use same script for multiple URLs - mansis - 08-29-2012

Please answer my below question urgently..

Consider that my healthcare web application is surving 100+ clients. For all of these 100 clients, URL is different and login credential is also different.

I need to login into all 100+ clients and needs to test few main pages (10 - 15 pages) are working fine or not.

Using QTP 10.0 version, I have script prepared to test few main pages for ONE client.

Now my question is how can I use above script for rest of 99 clients? Can data table help me? OR should I need to use looping. If yes, pls provide me the code.

As I am QTP beginner, Please suggest me best option in detail urgently..


RE: How to use same script for multiple URLs - sshukla12 - 08-29-2012

Hi,
To pass the url and username, password use datasheet and navigate to each row to pick the values.
Let me know in case of any help required.

Regards,
Sankalp


RE: How to use same script for multiple URLs - mansis - 08-29-2012

Sankalp, thanks a lot for your quick reply.. As I am beginer, I haven't used datasheet till now.. Can you please help me step by step to use datasheet in my case? How can I navigate each row to pick the value using datasheet?


RE: How to use same script for multiple URLs - sshukla12 - 08-29-2012

[attachment=1100][attachment=1100][quote='mansis' pid='22369' dateline='1346232386']

Hi,
Refer to the attachment

Regards,
Sankalp


RE: How to use same script for multiple URLs - mansis - 08-29-2012

Hi Sankalp,

Thanks for providing code. Using it, when I was running attached script in QTP and received error "The test run cannot continue due to a syntax error. Expected end of statement Line(1): "System Util.run DataTable("URL",dtGlobalSheet)". Can you please help me?

Script is ------


Code:
Datatable. Import"C:\Documents and Settings\mansi.shah\Desktop\book1.xlsx"
For i=1 to DataTable.RowCount
    System Util.run DataTable(“URL”,dtGlobalSheet)
    Browser().Page().Webedit().Set DataTable(“Username”,dtGlobalSheet)
    Browser().Page().Webedit().Set DataTable(“Password”,dtGlobalSheet)
             Browser("InSync :: Login").Page("InSync :: Login").WebButton("Login").Click
          
'Select facility'
Browser("InSync :: Login").Page("InSync :: Login_2").WebButton("Ok").Click

'Open Scheduler page'

Browser("InSync :: Login").Page("InSync :: Dash Board").Image("ctl00$Header1$Image2").Click
Wait (3)

'Access Patient Search page'

Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$Image3").Click
Browser("InSync :: Login").Page("InSync :: Patient Search").Image("Edit Patient").Click
Wait (3)


''Access Facesheet'
Browser("InSync :: Login").Page("InSync :: Patient Search").Image("ctl00$Header1$Image4").Click
Wait (3)

'Access New charge page'
Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$Image5").Click

'Access Document Manager'
Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$ibtndocumnetmgr").Click
Wait (3)

Browser("InSync :: Login").Close
Next
------------

Please review attached zip file for details

Thanks,
Mansi.


Hi,
Refer to the attachment

Regards,
Sankalp
[/quote]


RE: How to use same script for multiple URLs - ssvali - 08-29-2012

Please try below code

Code:
Set ObjExcel = CreateObject("Excel.Application")
ObjExcel.Visible = TRUE


Set oWorkbook = ObjExcel.Workbooks.Open "C:\Documents and Settings\mansi.shah\Desktop\book1.xlsx"
Set oWorksheet = oWorkbook.Worksheets("Sheet1")
rCnt = oWorkbook.Worksheets("Sheet1").UsedRange.Rows.Count

For i=2 to rCnt
URL = oWorkbook.Worksheets("Sheet1").Cells(i,1).Value
UserName = oWorkbook.Worksheets("Sheet1").Cells(i,2).Value
Password  = oWorkbook.Worksheets("Sheet1").Cells(i,3).Value
    System Util.run URL
    Browser().Page().Webedit().Set UserName
    Browser().Page().Webedit().Set Password
    Browser("InSync :: Login").Page("InSync :: Login").WebButton("Login").Click
'Select facility'
Browser("InSync :: Login").Page("InSync :: Login_2").WebButton("Ok").Click

'Open Scheduler page'

Browser("InSync :: Login").Page("InSync :: Dash Board").Image("ctl00$Header1$Image2").Click
Wait (3)

'Access Patient Search page'

Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$Image3").Click
Browser("InSync :: Login").Page("InSync :: Patient Search").Image("Edit Patient").Click
Wait (3)


''Access Facesheet'
Browser("InSync :: Login").Page("InSync :: Patient Search").Image("ctl00$Header1$Image4").Click
Wait (3)

'Access New charge page'
Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$Image5").Click

'Access Document Manager'
Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$ibtndocumnetmgr").Click
Wait (3)

Browser("InSync :: Login").Close
Next



RE: How to use same script for multiple URLs - mansis - 08-29-2012

ssvali - again syntax error. please review attched snapshot.


RE: How to use same script for multiple URLs - sshukla12 - 08-29-2012

Hi,

Keep the datasheet in some drive instead of desktop.
SystemUtil.run DataTable(“URL”,dtGlobalSheet)
pass the value of URL in datasheet
and please pass the browser and page name under the code which i provided.

Regards,
Sankalp

Regards,
Sankalp


RE: How to use same script for multiple URLs - mansis - 08-29-2012

Hi,

Sorry to say, Still it is Not working by giving attached syntax error.. Please review below updated script and attached zip file having script, datasheet and error screen shot.

------

Code:
Datatable.Import"D:\Datasheet\book1.xlsx"

For i=1 to DataTable.RowCount
    SystemUtil.run DataTable(“URL”,dtGlobalSheet)
    Browser(“InSync :: Login”).Page(“InSync :: Login”).Webedit().Set DataTable(“Username”,dtGlobalSheet)
    Browser(“InSync :: Login”).Page(“InSync :: Login”).Webedit().Set DataTable(“Password”,dtGlobalSheet)
              Browser("InSync :: Login").Page("InSync :: Login").WebButton("Login").Click
'Select facility'
Browser("InSync :: Login").Page("InSync :: Login_2").WebButton("Ok").Click

'Open Scheduler page'

Browser("InSync :: Login").Page("InSync :: Dash Board").Image("ctl00$Header1$Image2").Click
Wait (3)

'Access Patient Search page'

Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$Image3").Click
Browser("InSync :: Login").Page("InSync :: Patient Search").Image("Edit Patient").Click
Wait (3)


''Access Facesheet'
Browser("InSync :: Login").Page("InSync :: Patient Search").Image("ctl00$Header1$Image4").Click
Wait (3)

'Access New charge page'
Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$Image5").Click

'Access Document Manager'
Browser("InSync :: Login").Page("InSync :: Dash Board_2").Image("ctl00$Header1$ibtndocumnetmgr").Click
Wait (3)

Browser("InSync :: Login").Close
Next
------
Thanks,
Mansi.


RE: How to use same script for multiple URLs - sshukla12 - 08-30-2012

Hi,
Import .xls file instead od .xlsx

Regards,
Sankalp