Baksteen Posted August 7, 2012 Share Posted August 7, 2012 Hello, Today I was working on a script for a website. I was trying to make my script click on a <TD> element. It works now, but after allmost searching for 2 hours why my following code did not execute the $oQuery.click code but did execute the msgbox right above it: _IETagNameGetCollection($oIE, "TD") For $x = 0 To @extended - 1 $oQuery = _IETagNameGetCollection($oIE, "TD", $x) If _IEPropertyGet($oQuery, "outertext") = "Controle & Oplevering" Then MsgBox(1, "", "") $oQuery.click ExitLoop EndIf Next _IELoadWait($oIE) After changing this line If _IEPropertyGet($oQuery, "outertext") = "Controle & Oplevering" Then to: If _IEPropertyGet($oQuery, "outertext") == "Controle & Oplevering" Then It suddenly not only pops up the messagebox but also does the $oquery.click perfectly fine. Could someone care to explain me why this works this way? Kind regards, Baksteen Link to comment Share on other sites More sharing options...
jaberwacky Posted August 7, 2012 Share Posted August 7, 2012 (edited) = Tests if two values are equal. e.g. If $var= 5 Then (true if $var equals 5). Case insensitive when used with strings. == Tests if two strings are equal. Case sensitive. The left and right values are converted to strings if they are not strings already. This operator should only be used for string comparisons that need to be case sensitive. Edited August 7, 2012 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
water Posted August 7, 2012 Share Posted August 7, 2012 (edited) The difference between "=" and "==" is that "=" is case insensitive ("a" = "A"), whereas "==" does an exact match ("a" <> "A"). I can't explain why your script works with "==" and didn't with "=". In such a case I would suggest to split the command and do some error checking:$sResult = _IEPropertyGet($oQuery, "outertext") If @error Then ... ; do some error handling If $sResult = "Controle & Oplevering" Then Edited August 7, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Baksteen Posted August 7, 2012 Author Share Posted August 7, 2012 yeah, the weird thing is it did execute the msgbox code, but not the following line after it, when using a single '=' When using double '==' it executes all the following code. The explanation from lacastiglione does not explain that... Your's (water) is more usefull, even though it doesn't answer the question it might help better in the future. Thanks for that. Link to comment Share on other sites More sharing options...
water Posted August 7, 2012 Share Posted August 7, 2012 So the comparison is true if you use "=" or "==" but $oQuery.clickfails when used with "=". As you use the IE UDF I would make sure that the COM error handler is activated and gives you detailed error information when problems with objects are encountered. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Baksteen Posted August 7, 2012 Author Share Posted August 7, 2012 So the comparison is true if you use "=" or "==" but $oQuery.clickfails when used with "=". As you use the IE UDF I would make sure that the COM error handler is activated and gives you detailed error information when problems with objects are encountered. You are right, I totally forgot about the error handler. I will check this out tomorrow as I'm going home right now and am tired. Link to comment Share on other sites More sharing options...
Baksteen Posted August 8, 2012 Author Share Posted August 8, 2012 With or without error handler doesn't change anything. The script doesn't throw any errors at all. See my console (paths are edited out, can't post any corporate information): >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "" /UserParams +>12:15:36 Starting AutoIt3Wrapper v.2.1.0.33 Environment(Language:0413 Keyboard:00020409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X86) >Running AU3Check (1.54.22.0) from:C:Program FilesAutoIt3 +>12:15:36 AU3Check ended.rc:0 >Running:(3.3.8.1):C:Program FilesAutoIt3autoit3.exe "" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop +>12:15:44 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 10.526 Link to comment Share on other sites More sharing options...
Baksteen Posted August 8, 2012 Author Share Posted August 8, 2012 Anyway, I now know to try double == when there are problems with single = ... Hopefully the devs will take a look at this at some point (or maybe they are able to explain why this happens). Link to comment Share on other sites More sharing options...
trancexx Posted August 8, 2012 Share Posted August 8, 2012 Youu mixed up two, three different things. If you want to call object's method then use braces after the method name. If you don't do that the call may fail. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Baksteen Posted August 8, 2012 Author Share Posted August 8, 2012 (edited) Hi Trancexx, Thanks for your reply. Do you mean I should use $oQuery.click() instead of $oQuery.click ? Or do I get it wrong? Sorry if I'm misunderstanding, I'm still in early stages of learning to work with methods. Edited August 8, 2012 by Baksteen Link to comment Share on other sites More sharing options...
trancexx Posted August 8, 2012 Share Posted August 8, 2012 Yes, click is a method. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
notsure Posted August 9, 2012 Share Posted August 9, 2012 That still does not explain why the "==" executes the code correctly and the "=" does not. Link to comment Share on other sites More sharing options...
trancexx Posted August 9, 2012 Share Posted August 9, 2012 That's very likely just bad coding. I say that problem doesn't exist. Anyone can prove me wrong of course. Write some (good) code that would show the issue. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
notsure Posted August 9, 2012 Share Posted August 9, 2012 (edited) The problem does exist, i tried to reproduce it by using as much HTML code as the original site has but i can't reproduce it. It seems like the website itself is coded in a way which is causing this behaviour (eventho its W3C compatible). (Actually; i'm not "baksteen" but i've seen the problem occur. At my PC and his.) Edited August 9, 2012 by notsure Link to comment Share on other sites More sharing options...
trancexx Posted August 9, 2012 Share Posted August 9, 2012 (edited) An I've heard people saying Earth is round. I guess ausies have capability of hanging upside down then. Come on! Edited August 9, 2012 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
notsure Posted August 9, 2012 Share Posted August 9, 2012 (edited) An I've heard people saying Earth is round. I guess ausies have capability of hanging upside down then. Come on!I can record it on video if you like. But then again, i think it's the website which is causing the problem, not AutoIT.Also, why would we lie about this happening, rofl. Edited August 9, 2012 by notsure Link to comment Share on other sites More sharing options...
trancexx Posted August 9, 2012 Share Posted August 9, 2012 It's not about lying, it's about not understanding, not knowing, bad coding, stuff like that. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
notsure Posted August 9, 2012 Share Posted August 9, 2012 So $oQuery.click is bad coding and should be $oQuery.click()... i understand, you told that before, but it does not _explain_ why the website behaves like that. That's what i'm trying to figure out. Link to comment Share on other sites More sharing options...
trancexx Posted August 9, 2012 Share Posted August 9, 2012 Behaves like what? Use your head. Think, think. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Exit Posted August 9, 2012 Share Posted August 9, 2012 perhaps there are two instances of the string. One with exact case spelling and one with other spelling. Just remove the "exitloop" and look if there are more than one matching events. App: Au3toCmd UDF: _SingleScript() 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