Jump to content

Why doesn't this function work?


Recommended Posts

Hi I'm trying to cut down on my code so tried to take this code which works fine 

;Test "For Vouchers" line on main page
$PleaseUploadTitles= _IETagNameGetCollection($oIE, "label")
For $PleaseUploadTitle In $PleaseUploadTitles
   ;Use string in string as 2nd half of variable is a unique number
    If $PleaseUploadTitle.InnerText == "Upload Type"        Then
       ;    If StringInStr($PleaseUploadTitle.InnerText, "Upload Costs")        Then

            if @Error then
            ConsoleWrite(@CRLF & "Error For checking the upload costs label")

            Endif
        MsgBox(64, 'Test Passed', 'For checking the upload costs label with value: ' & $PleaseUploadTitle.InnerText, 2)
        Sleep(2500)
        ConsoleWrite(@CRLF & "$class_value: " &  $PleaseUploadTitle.innertext)

         ;Declare test result and test passed
         MsgBox($MB_SYSTEMMODAL, "Test" & $TestCount & "Test Result For checking the upload costs label with value: ", "Test Passed: Header exists and equals:"& $PleaseUploadTitle.innertext, 2)
         ConsoleWrite(@CRLF & @CRLF & "Test" & $TestCount &"Test Passed: For checking the upload costs label with value: "& $PleaseUploadTitle.innertext)
         FileWrite($TestLog, @CRLF & "Test" & $TestCount & "Test Passed: For checking the upload costs label with value: "& $PleaseUploadTitle.innertext)
         FileWrite($TestResults, @CRLF & "Test" & $TestCount &"Test Passed: For checking the upload costs label with value: "& $PleaseUploadTitle.innertext)

        ExitLoop
        Sleep(4000)


    EndIf
 Next

and turn it into a function like so 

Func CompareOnInnerText_SearchViaTagNameCollection($oIE, $IETags, $VariableToTest, $WebElementToSearch)
   $IETags = _IETagNameGetCollection($oIE, $WebElementToSearch)
For IETag In $IETags
    If IETag.InnerText == $VariableToTest        Then
       ;    If StringInStr(IETag.InnerText, "Upload Costs")        Then

            if @Error then
            ConsoleWrite(@CRLF & "Error finding:" & $VariableToTest)

            Endif
        MsgBox(64, 'Test Passed', "For " & $VariableToTest & " with value: " & IETag.InnerText, 2)
        Sleep(2500)
        ConsoleWrite(@CRLF & "$class_value: " &  IETag.innertext)

         ;Declare test result and test passed
         MsgBox($MB_SYSTEMMODAL, "Test" & $TestCount & "Test Result For " & $VariableToTest & " with value: ", "Test Passed: Header exists and equals:"& IETag.innertext, 2)
         ConsoleWrite(@CRLF & @CRLF & "Test" & $TestCount &"Test Passed: For " & $VariableToTest & " with value: "& IETag.innertext)
         FileWrite($TestLog, @CRLF & "Test" & $TestCount & "Test Passed: For " & $VariableToTest & " with value: "& IETag.innertext)
         FileWrite($TestResults, @CRLF & "Test" & $TestCount &"Test Passed: For " & $VariableToTest & " with value: "& IETag.innertext)
$TestCount = $TestCount + 1
        ExitLoop
        Sleep(4000)

    EndIf
 Next

EndFunc

Because it says my For statement is badly formatted?

GenericFunctions.au3" (35) : ==> "For" statement is badly formatted.:
For IETag In $IETags
For ^ ERROR

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...