Results 1 to 5 of 5
  1. #1

    a big task-help me in vbscript or java script

    i have a site http://www.amjkt.org/mba/Default.aspx?
    in this i will enter 100001 then i will get the all the information.this details i want to send to the xls sheet.
    Also i want this details for 100001 to 1000020.
    Plz help me in doing this

  2. #2

    Re: a big task-help me in vbscript or java script

    Hi Kirshna Prasad,

    I hope this code can help you.

    'TestComplete VB Script
    'Create a blank excelfile with results.xls 'in testcompelete 'project folder

    'Execute EnterAccountNumber Routine - Change the Admin number to required loop

    Function ReadTableData

    Dim resultsArray(100),k

    Set p = Sys.Process("IEXPLORE")
    Set w = p.Window("IEFrame", "*", 1).Window("Internet Explorer_Server")
    Set Page = w.Page("*")

    Set resultsDiv=Page.Document.All.WaitItem("28",1000)

    Set Table = resultsDiv

    ' Goes through the rows and cells of the table
    For i = 1 To Table.rows.length - 1
    For j = 0 To Table.rows(i).cells.length - 1
    ' Log.Message Table.rows(i).cells(j).innerText

    Call WriteToExcel(resultsArray)

    End Function

    Function WriteToExcel(resultsArray)
    Dim cflag


    Set objExcel = Sys.OleObject("Excel.Application")
    builtIn.Delay(300) ' Wait until Excel starts
    lstrResultFile = Project.Path & "\Results.xls" objExcel.Workbooks.open(lstrResultFile)
    Set objXlSheet=objExcel.ActiveWorkbook.Worksheets(1)

    objExcel.Visible = false

    lintcolcount = objXlSheet.UsedRange.Columns.Count
    'Write side by side only the data collected without the header names

    For i = 2 To lintlastRowCount
    If UCase(Trim(objXlSheet.Cells(i,1))) =UCase(Trim(resultsArray(k))) then

    objXlSheet.Cells(i,lintcolcount) = resultsArray(k+1)
    End If

    if cflag=False then

    For i=1 To Ubound(resultsArray) Step 2
    objXlSheet.Cells(i,1) = resultsArray(i)
    objXlSheet.Cells(i,2) = resultsArray(i+1)

    End if

    Call objExcel.ActiveWorkbook.Save()
    Call objExcel.ActiveWorkbook.Close ()
    set objExcel=nothing
    set objXlsheet=nothing
    End Function

    Function EnterAccountNumber

    Dim w1,w2,w3

    Set w1 = Sys.Process("IEXPLORE").Window("IEFrame", "*")
    Set w2 = w1.Window("Edit")
    Call w2.Keys("http://www.amjkt.org/mba/Default.aspx")
    Call w2.Keys("[Enter]")
    Set w2 = w1.Window("Internet Explorer_Server")

    For AdminNumber = 100001 to 100002
    Set w1 = w2.Page("*").document.all

    Call w1.Refresh
    Set w3 = w1.WaitItem("txtseatno",1000)

    Call w1.Item("Button2").Click
    'Please wait until download completes: "http://www.amjkt.org/mba/Default.aspx"
    Call w2.Wait

    End Function

    Let me know if this code worked for you are not .


  3. #3

    Re: a big task-help me in vbscript or java script

    Hi kautilya

    Thanks for your reply.It help up to some extent only.My code is:
    Sub main
    end sub
    after this i copied all the code which u have posted and also i run the script from the main.But still i am getting the error that main routine was not found. i have a doubt that whether i should paste the entire code in between the sub and end sub or after the end sub.
    it would be great if u send the code by using javascripts.
    Can u help me in this.

    Thanx and Regards,
    Krishna Prasad

  4. #4

    Re: a big task-help me in vbscript or java script


    Just you have to copy from
    'Testcomplete VB script
    from the above lines of code and there is No need to add any extra lines - make EnterAccountNumber Function as main routine and press F9
    from code explorer runt he EnterAcctount number function
    it will start the execution

    Note : Do not forget to creat a results.xls file in the Tst complete project folder

    Let me know did the above lines helped you.

    Good Luck

  5. #5

    Re: a big task-help me in vbscript or java script

    Hi Krishna,

    Please see the 'Script Project Item Editor' help topic for information on how to set a main routine.
    Best regards,
    David - SmartBear Support



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:49 PM.

Copyright BetaSoft Inc.