oemript Posted March 6, 2018 Share Posted March 6, 2018 (edited) Please see following image, there is a language selection before entering web page, I would like to know on how to code on clicking English as shown below https://shopee.com.my/ Does anyone have any suggestions? Thanks in advance for any suggestions Edited March 6, 2018 by oemript Link to comment Share on other sites More sharing options...
Subz Posted March 6, 2018 Share Posted March 6, 2018 Try: #include <IE.au3> Local $oButtons Local $oIE = _IECreate("https://shopee.com.my/", 1) Sleep(5000) Local $oDivs = _IETagNameGetCollection($oIE, "div") For $oDiv In $oDivs If $oDiv.ClassName = "language-selection__list" Then $oButtons = _IETagNameGetCollection($oDiv, "button") For $oButton In $oButtons If $oButton.InnerText = "English" Then _IEAction($oButton, "click") Next EndIf Next Link to comment Share on other sites More sharing options...
oemript Posted March 6, 2018 Author Share Posted March 6, 2018 (edited) Please see following image, there is an error as shown below Do you have any suggestions on what wrong it is? Thank you very much for suggestions (^v^) Edited March 6, 2018 by oemript Link to comment Share on other sites More sharing options...
oemript Posted March 6, 2018 Author Share Posted March 6, 2018 There is an error on $oButton. Do you have any suggestions on what wrong it is? Thank you very much for suggestions (^v^) Link to comment Share on other sites More sharing options...
Danp2 Posted March 6, 2018 Share Posted March 6, 2018 11 hours ago, Subz said: $oButton.InnerText Try changing this to $oButton.innerText (note the lowercase I. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
oemript Posted March 6, 2018 Author Share Posted March 6, 2018 (edited) Please see following image, I still get an error with lower case as shown below Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited March 6, 2018 by oemript Link to comment Share on other sites More sharing options...
Danp2 Posted March 6, 2018 Share Posted March 6, 2018 Try using _IEPropertyGet instead. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
oemript Posted March 6, 2018 Author Share Posted March 6, 2018 For _IEPropertyGet under Help, there is no browser properties for "click" action. Do you have any suggestions on how _IEPropertyGet works for clicking button? Thanks, to everyone very much for any suggestions (^v^) Link to comment Share on other sites More sharing options...
oemript Posted March 7, 2018 Author Share Posted March 7, 2018 (edited) Please see following image, would it be possible to handle the error? so the rest of coding can able to run as shown below: Instead of solving the error on button, I prefer to skip this error properly, so the rest of coding can be run. Does anyone have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited March 7, 2018 by oemript Link to comment Share on other sites More sharing options...
oemript Posted March 7, 2018 Author Share Posted March 7, 2018 (edited) Referring to following image, there is an error on Button's issue, and I would like to know on how handle and skip this error (not solve the error, since I get no idea, if someone gets an idea on solving it, then it would be great), and keep the rest of codes running, such as show MsgBox in this case. Does anyone have any suggestions? Thanks in advance for any suggestions ========================================================================== #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <IE.au3> ; Create a constant variable in Local scope of the filepath that will be read/written to. ; Local Const $sFilePath = _WinAPI_GetTempFileName(@TempDir Local $oButtons Local $oIE = _IECreate("https://shopee.com.my/", 1) Sleep(5000) Local $oDivs = _IETagNameGetCollection($oIE, "div") For $oDiv In $oDivs If $oDiv.ClassName = "language-selection__list" Then $oButtons = _IETagNameGetCollection($oDiv, "button") For $oButton In $oButtons If $oButton.innerText = "English" Then _IEAction($oButton, "click") Next EndIf Next MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10) Edited March 7, 2018 by oemript Link to comment Share on other sites More sharing options...
Danp2 Posted March 7, 2018 Share Posted March 7, 2018 @oemript You keep asking the same thing over and over without showing any effort in solving the problem yourself. That isn't how this forum works. Were here to assist and point you in the right direction, but the expectation is that you take this information and use it to solve the problem on your own. 13 hours ago, oemript said: For _IEPropertyGet under Help, there is no browser properties for "click" action. That's correct. You can't click using _IEPropertyGet. However, if you look in the help file, you will see that it can be used to retrieve the innertext of the designated control. Since this is the area where your script was failing, I suggested that you switch to _IEPropertyGet. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Andreik Posted March 7, 2018 Share Posted March 7, 2018 Check out ObjEvent() examples from help file. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 7, 2018 Moderators Share Posted March 7, 2018 @oemript you have been around long enough to know to keep it to one thread. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
oemript Posted March 7, 2018 Author Share Posted March 7, 2018 This post is to handle and skip error, and the other post is to click the Button, Both post are on different issue, would it be OK? Thanks, to everyone very much for any suggestions (^v^) Link to comment Share on other sites More sharing options...
oemript Posted March 7, 2018 Author Share Posted March 7, 2018 (edited) 13 minutes ago, Andreik said: Check out ObjEvent() examples from help file. Please see following image, I would like to know on how ObjEvent help on issues related to innerText or Clicking button. Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited March 7, 2018 by oemript Link to comment Share on other sites More sharing options...
oemript Posted March 7, 2018 Author Share Posted March 7, 2018 (edited) On 3/6/2018 at 9:30 AM, Subz said: Try: #include <IE.au3> Local $oButtons Local $oIE = _IECreate("https://shopee.com.my/", 1) Sleep(5000) Local $oDivs = _IETagNameGetCollection($oIE, "div") For $oDiv In $oDivs If $oDiv.ClassName = "language-selection__list" Then $oButtons = _IETagNameGetCollection($oDiv, "button") For $oButton In $oButtons If $oButton.InnerText = "English" Then _IEAction($oButton, "click") Next EndIf Next Please see following image, I tried, and the button is clicked successfully, but there is an error, this error stops running the rest of coding such as MsgBox as shown below, that is the error issues. Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited March 7, 2018 by oemript Link to comment Share on other sites More sharing options...
Danp2 Posted March 7, 2018 Share Posted March 7, 2018 3 minutes ago, oemript said: Please see following image, I tried, and the button is clicked, but there is an error Are you sure the button is being clicked? I'm thinking not. However, you could rewrite that section of code like this, so that it stops looping after the correct button is found -- For $oButton In $oButtons If $oButton.InnerText = "English" Then _IEAction($oButton, "click") ExitLoop EndIf Next oemript 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
oemript Posted March 7, 2018 Author Share Posted March 7, 2018 (edited) 15 minutes ago, Danp2 said: For $oButton In $oButtons If $oButton.InnerText = "English" Then _IEAction($oButton, "click") ExitLoop EndIf Next Yes, the language selection list is disappeared, and error occurs as shown below Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited March 7, 2018 by oemript Link to comment Share on other sites More sharing options...
Danp2 Posted March 7, 2018 Share Posted March 7, 2018 1 minute ago, oemript said: Yes, the language selection list is disappeared, and error occurs as shown below The issue is that you have a collection of button objects that you are traversing. Once you click on a button, the buttons no longer exist, yet you continue to process the collection. Change the code like I indicated above and the error should disappear. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
oemript Posted March 7, 2018 Author Share Posted March 7, 2018 (edited) 6 minutes ago, Danp2 said: The issue is that you have a collection of button objects that you are traversing. Once you click on a button, the buttons no longer exist, yet you continue to process the collection. Change the code like I indicated above and the error should disappear. I get it, there are 2 loops, 1) ExitLoop only exit for "For $oButton In $oButtons", 2) How to exit "For $oDiv In $oDivs" as well if only if "$oButton.InnerText = "English" . There are 2 loop needed to exit here. Do you have any suggestions? Thanks, to everyone very much for any suggestions (^v^) Edited March 7, 2018 by oemript 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