CaptainBeardsEyesBeard Posted April 23, 2020 Share Posted April 23, 2020 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 More sharing options...
FrancescoDiMuro Posted April 23, 2020 Share Posted April 23, 2020 (edited) 2 minutes ago, CaptainBeardsEyesBeard said: For IETag In $IETags should be For $IETag In $IETags and all the IETag in your script should be replaced with $IETag Edited April 23, 2020 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted April 23, 2020 Author Share Posted April 23, 2020 god damn thanks Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now