oemript Posted March 8, 2018 Share Posted March 8, 2018 (edited) Referring to following coding, there are 2 cases for testing: Case 1 when I tried this approach "_IEAction($oInput, "focus")" and get error as shown below Case 2 Furthermore, when I tried another approach, the suggested lists cannot pop up as shown on below image. Does anyone have any suggestions on what wrong it is and how to handle those error properly? Thanks in advance for any suggestions expandcollapse popup#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/") 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") ExitLoop 2 EndIf Next EndIf Next Sleep(5000) Local $sSendKey = "k" Local $sSearch = "" ;========================================================================== ;Case 1 Local $oInputs = _IETagNameGetCollection($oIE, "input") _IEAction($oInputs, "focus") ControlSend(_IEPropertyGet($oInputs, "title"), "", "", $sSendKey) Sleep(2000) ControlSend(_IEPropertyGet($oInputs, "title"), "", "", "{DOWN}") Sleep(2000) Local $oDivs = _IETagNameGetCollection($oInputs, "a") ;========================================================================== ;Case 2 ;Local $oInputs = _IETagNameGetCollection($oIE, "input") ;For $oInput In $oInputs ;If StringInStr($oInput.ClassName, "shopee-searchbar-input__input") Then; ;$oInput.Value = "k" ;ExitLoop ;EndIf ;Next ;========================================================================== Sleep(3000) For $oDiv In $oDivs If StringInStr($oDiv.ClassName, "shopee-searchbar-hints__entry__product-name") Then $sSearch &= StringStripWS($oDiv.Innertext, 7) & @CRLF Next MsgBox(32, "Search Items", $sSearch ) Edited March 8, 2018 by oemript Link to comment Share on other sites More sharing options...
Danp2 Posted March 8, 2018 Share Posted March 8, 2018 Local $oInputs = _IETagNameGetCollection($oIE, "input") _IEAction($oInputs, "focus") You showed two different versions of this code. The first (in the image), you showed $oInput (without the 's'), so this variable wouldn't exist at that stage. In the above example, you have a collection of objects ($oInputs) that you are trying to pass to the function, _IEAction. You can't pass a collection into this function. Instead, you need to process the collection with a For loop. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted March 8, 2018 Share Posted March 8, 2018 Local $oDivs = _IETagNameGetCollection($oInputs, "a") For $oDiv In $oDivs If StringInStr($oDiv.ClassName, "shopee-searchbar-hints__entry__product-name") Then $sSearch &= StringStripWS($oDiv.Innertext, 7) & @CRLF Next Again, the code in the image doesn't match the posted code. Which one is correct? How do you know a match is being found? Try rewriting the code like this -- $oLinks = _IETagNameGetCollection($oIE, "a") For $oLink In $oLinks If StringInStr($oLink.ClassName, "shopee-searchbar-hints__entry__product-name") Then ConsoleWrite('Found matching link!' & @CRLF) $sSearch &= StringStripWS($oLink.Innertext, 7) & @CRLF EndIf Next Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
oemript Posted March 8, 2018 Author Share Posted March 8, 2018 (edited) Please see following image for both cases: Case 1 Case 2 Do you have any suggestions? Thank you very much for any suggestions (^v^) Edited March 8, 2018 by oemript Link to comment Share on other sites More sharing options...
Danp2 Posted March 8, 2018 Share Posted March 8, 2018 28 minutes ago, oemript said: Do you have any suggestions? Yes, go back and reread my prior response. 1 hour ago, Danp2 said: you have a collection of objects ($oInputs) that you are trying to pass to the function, _IEAction. You can't pass a collection into this function. Instead, you need to process the collection with a For loop. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Subz Posted March 8, 2018 Share Posted March 8, 2018 expandcollapse popup#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/") 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") ExitLoop 2 EndIf Next EndIf Next Sleep(5000) Local $sSendKey = "k" Local $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If StringInStr($oInput.ClassName, "searchbar-input") Then _IEAction($oInput, "focus") ControlSend(_IEPropertyGet($oIE, "title"), "", "", $sSendKey) Sleep(2000) _IEAction($oInput, "click") Sleep(2000) ExitLoop EndIf Next Local $oLinks = _IETagNameGetCollection($oIE, "a") Sleep(3000) For $oLink In $oLinks If StringInStr($oLink.ClassName, "shopee-searchbar-hints") Then $sSearch &= StringStripWS($oLink.Innertext, 7) & @CRLF Next MsgBox(32, "Search Items", $sSearch ) oemript 1 Link to comment Share on other sites More sharing options...
oemript Posted March 9, 2018 Author Share Posted March 9, 2018 10 hours ago, Subz said: expandcollapsepopup expandcollapse popup#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/") 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") ExitLoop 2 EndIf Next EndIf Next Sleep(5000) Local $sSendKey = "k" Local $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If StringInStr($oInput.ClassName, "searchbar-input") Then _IEAction($oInput, "focus") ControlSend(_IEPropertyGet($oIE, "title"), "", "", $sSendKey) Sleep(2000) _IEAction($oInput, "click") Sleep(2000) ExitLoop EndIf Next Local $oLinks = _IETagNameGetCollection($oIE, "a") Sleep(3000) For $oLink In $oLinks If StringInStr($oLink.ClassName, "shopee-searchbar-hints") Then $sSearch &= StringStripWS($oLink.Innertext, 7) & @CRLF Next MsgBox(32, "Search Items", $sSearch ) I am very appreciated for all your help Thanks, to everyone very much for any suggestions (^v^) 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