SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to use the Call Function

    Hi,

    I have 2 scripts.I would like to know how to use 1 script in the 2 script.(means how to call the function).
    Please help me anybody.
    ThankYou

  2. #2
    Senior Member
    Join Date
    Feb 2001
    Location
    USA
    Posts
    776
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    First example.
    Lets say you have script called script1 and has following function.

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Function GetFirstName(sFullName)
    sFName=trim(mid(sFullName,1,8)
    GetFirstName=sFName
    End Function</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Call GetFirstName("Prashant Patel")

    Second example.
    Lets say you have script called script1 and script2.

    Script1 has following code.
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Function GetFirstName(sFullName)
    sFName=trim(mid(sFullName,1,8)
    GetFirstName=sFName
    End Function</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Script2 has following code.
    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Function GetLastName(sFullName)
    sLName=trim(right(sFullName,5)
    GetLastName=sLName
    End Function</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Now save Script1 as c:\Script1.vbs and Script2 as c:\Script2.vbs.

    Now open script1 and delete everything that you have under Script1 and type following.

    ExecuteFile "c:\Script1.vbs"
    ExecuteFile "c:\Script2.vbs"

    call GetFirstName("Prashant Patel")
    call GetLastName("Prashant Patel")

    Regards,
    Prashant Patel
    Thanks,
    Prashant Patel

  3. #3
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    Hi Prashant,

    These are my scripts.
    script one is (This scrippt is Mercury Tours)
    Browser("Welcome: Mercury").Page("Welcome: Mercury").WebEdit("userName").Set "eewwerf"

    Browser("Welcome: Mercury").Page("Welcome: Mercury").WebEdit("password").SetSecure "43545f7e29f4a9"

    Browser("Welcome: Mercury").Page("Welcome: Mercury").Image("Sign-In").Click 32,6

    Browser("Welcome: Mercury").Page("Find a Flight:").Sync

    Second Script is (This script also Mercury Tours)
    Browser("Welcome: Mercury").Page("Welcome: Mercury").Link("Car Rentals").Click

    Browser("Welcome: Mercury").Page("Under Construction:").Sync


    How can i write the Function above scripts.
    Could u please tell me.
    ThankYou

  4. #4
    Senior Member
    Join Date
    Feb 2001
    Location
    USA
    Posts
    776
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    Hi Saiteja,

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Function Login(sUid,sPwd)
    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Welcome: Mercury&quot.WebEdit(&quot;userName&quot.Set sUid

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Welcome: Mercury&quot.WebEdit(&quot;password&quot.SetSecure sPwd

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Welcome: Mercury&quot.Image(&quot;Sign-In&quot.Click 32,6

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Find a Flight:&quot.Sync

    End Function

    Function Welcome()

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Welcome: Mercury&quot.Link(&quot;Car Rentals&quot.Click

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Under Construction:&quot.Sync

    End Function</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Prashant Patel
    Thanks,
    Prashant Patel

  5. #5
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    Hi Prasant

    When try below code It's not going to next page(Find a flight Page). Can i run this script directly or can i call this function to
    different script. Could you please let me know.
    ThankYou Very Much
    Function Login()
    Browser("Welcome: Mercury").Page("Welcome: Mercury").WebEdit("userName").Set "eewwerf"

    Browser("Welcome: Mercury").Page("Welcome: Mercury").WebEdit("password").SetSecure "43545f7e29f4a9"

    Browser("Welcome: Mercury").Page("Welcome: Mercury").Image("Sign-In").Click 32,6
    End Function
    Browser("Welcome: Mercury").Page("Find a Flight:").Sync

  6. #6
    Junior Member
    Join Date
    Sep 2005
    Posts
    4
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    Hi EveryBody,

    Can anybody give me some solution to declare functions as public and call them in another script by passing parameters......

    thanks
    venki
    Regards
    venki

  7. #7
    Member
    Join Date
    Aug 2005
    Location
    Chennai
    Posts
    96
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    You can always specify functions inside an .vbs file and then do either of the following
    1.executefile filename
    2.attach the file into the library

    now the function declared inside the .vbs is public to the current test and u can pass arguments to it and perform the action
    Rajesh Kumar Chengalpathy

  8. #8
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    If you want to use a function as public i.e. in any of the actions in the script then you need to put that function in a library file and associate it with the test.

  9. #9
    Senior Member
    Join Date
    Feb 2001
    Location
    USA
    Posts
    776
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    Hi Saiteja,

    In order to use call this functions in different script, do following.

    1)Create a file called c:\Login.vbs
    2)Put below code in above file and save it.

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Function Login(sUid,sPwd)
    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Welcome: Mercury&quot.WebEdit(&quot;userName&quot.Set sUid

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Welcome: Mercury&quot.WebEdit(&quot;password&quot.SetSecure sPwd

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Welcome: Mercury&quot.Image(&quot;Sign-In&quot.Click 32,6

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Find a Flight:&quot.Sync

    End Function</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">3)Create file called c:\Welcome.vbs
    4)Put below code in above file and save it.

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">Function Welcome()

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Welcome: Mercury&quot.Link(&quot;Car Rentals&quot.Click

    Browser(&quot;Welcome: Mercury&quot.Page(&quot;Under Construction:&quot.Sync

    End Function</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">5)Open the different script and Enter below code

    ExecuteFile "c:\Login.vbs"
    ExecuteFile "c:\Welcome.vbs"

    call Login("Prashant","Patel")
    call Welcome()

    Prashant Patel
    Thanks,
    Prashant Patel

  10. #10
    Senior Member
    Join Date
    Oct 2005
    Posts
    157
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to use the Call Function

    Hi Prashant,

    Thanks for immediate replay. But when i save the file i have only save as type is Quick Test Tests. I couldn't save as .vbs.
    Could u please tell me how tosave the .vbs.
    one more thing i don't have VB software in my machine. is their any problem.

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 03:49 AM.

Copyright BetaSoft Inc.