MRAJ Posted May 10, 2018 Share Posted May 10, 2018 My script not able to click on the Clear Numbers which is button type. Below is the script and HTML page of that. <input onclick="clearSIFields(formx, this, 'fieldsinumber', 12)" type="button" value="Clear Numbers"> Local $oIE = _IECreate($URL,0,1) Local $hWnd = WinWait("[CLASS:IEFrame]", "", 10) WinWaitActive($hWnd) Sleep(2000) ControlClick($hWnd, "Home - Internet Explorer", "[CLASS:IEFrame; INSTANCE:1]") Sleep(2000) $oButtons = _IETagnameGetCollection($oIE, "input") For $oButton in $oButtons If String($oButton.value) = "Clear Numbers" Then _IEAction($oButton, "click") ExitLoop EndIf Next let me know how to achieve this. Link to comment Share on other sites More sharing options...
Danp2 Posted May 10, 2018 Share Posted May 10, 2018 You haven't given us enough details. At a minimum, post the results shown in the Scite output panel when you run the script with F5. You could also add some logging using ConsoleWrite() so that you can know things like how many elements were found, their values, etc. This will often allow you to see what is going wrong in your script and allow you to come up with a solution yourself. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 10, 2018 Author Share Posted May 10, 2018 I am not seeing any errors in Output console. Let me know how i can use ConsoleWrite() to know how many elements were found? Link to comment Share on other sites More sharing options...
Danp2 Posted May 10, 2018 Share Posted May 10, 2018 If you look at the help file for _IETagNameGetCollection, it states Quote Success: an object variable containing the specified Tag collection, @extended = specified Tag count. So you could do something like this -- ConsoleWrite("*** " & @extended & " elements found! ***" & @crlf) In addition, you could add a line to your loop to view details on each element, such as -- ConsoleWrite("Found - " & $oButton.value & @crlf) The uses for ConsoleWrite are limitless! Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 11, 2018 Author Share Posted May 11, 2018 Found the below output *** 0 elements found! *** "C:\Desktop\portal.au3" (35) : ==> Variable used without being declared.: ConsoleWrite("Found - " & $oButton.value & @crlf) ConsoleWrite("Found - " & ^ ERROR >Exit code: 1 Time: 13.05 Link to comment Share on other sites More sharing options...
Danp2 Posted May 11, 2018 Share Posted May 11, 2018 You need to figure out -- 1) Why no elements were found with _IETagNameGetCollection 2) Why you received the variable not found error. On this one, I suspect that you put the ConsoleWrite outside of the For loop. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 11, 2018 Author Share Posted May 11, 2018 $oButtons = _IETagnameGetCollection($oIE, "input") For $oButton in $oButtons If StringInStr($oButton.value) = "Clear Numbers" Then _IEAction($oButton, "click") ConsoleWrite("*** " & @extended & " elements found! ***" & @crlf) Sleep(2000) ConsoleWrite("Found - " & $oButton.value & @crlf) ExitLoop EndIf Next i tried like the above..is that correct? Link to comment Share on other sites More sharing options...
Danp2 Posted May 11, 2018 Share Posted May 11, 2018 No. The initial consolewrite would need to go directly after the call to _IETagNameGetCollection for the value of @extended to be correct. The other consolewrite should go directly after the For statement. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 11, 2018 Author Share Posted May 11, 2018 $oButtons = _IETagnameGetCollection($oIE, "input") ConsoleWrite("*** " & @extended & " elements found! ***" & @crlf) For $oButton in $oButtons ConsoleWrite("Found - " & $oButton.value & @crlf) If StringInStr($oButton.value) = "Clear Numbers" Then _IEAction($oButton, "click") Sleep(2000) ExitLoop EndIf Next i tried and output console gives below result: *** 0 elements found! *** >Exit code: 0 Time: 16.98 Link to comment Share on other sites More sharing options...
Danp2 Posted May 11, 2018 Share Posted May 11, 2018 Ok... so now you need to figure out why. Is the desired element contained within a frame? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 11, 2018 Author Share Posted May 11, 2018 No..the desired element i am not able to find. Link to comment Share on other sites More sharing options...
Danp2 Posted May 11, 2018 Share Posted May 11, 2018 Can you save the web page to a file and then post it here? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 11, 2018 Author Share Posted May 11, 2018 Link to comment Share on other sites More sharing options...
Danp2 Posted May 11, 2018 Share Posted May 11, 2018 That's an image. I was expecting you to save the web page's HTML to a file and post it here as an attachment. P.S. What this bit about "5 frames found"? You have previously stated that there is only a single frame. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 16, 2018 Author Share Posted May 16, 2018 <input onclick="clearSIFields(formx, this, 'fieldsinumber', 12)" type="button" value="Clear Numbers"> Please let me know the next step.Above is the HTML page for the particular Clear Numbers. Link to comment Share on other sites More sharing options...
Danp2 Posted May 16, 2018 Share Posted May 16, 2018 @MRAJ That's the same HTML you posted in your OP. This only shows us a single html element, which you are saying that you can't locate using the _IE functions. For further assistance, you will need to do as previously asked -- On 5/11/2018 at 8:41 AM, Danp2 said: I was expecting you to save the web page's HTML to a file and post it here as an attachment. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 17, 2018 Author Share Posted May 17, 2018 (edited) Attached is HTML page. Edited May 17, 2018 by MRAJ Link to comment Share on other sites More sharing options...
Danp2 Posted May 17, 2018 Share Posted May 17, 2018 @MRAJ A quick review of this file shows that it doesn't contain the element you are attempting to click. It also reveals that there are 5 iframes involved. You need to determine which iframe contains the desired elements before you can proceed any further. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MRAJ Posted May 17, 2018 Author Share Posted May 17, 2018 Could you help me the 5 frames which contains the desired elements and how to achiveve them..as i am not able to find any solution..i tired my best but not getting success. Link to comment Share on other sites More sharing options...
Danp2 Posted May 17, 2018 Share Posted May 17, 2018 Two options -- Use the browser's DOM Explorer to figure out which frame contains the desired elements. Look at the help file example for _IEFrameGetCollection. Modify this to run against your webpage and see if you can determine which frame you need to access Latest Webdriver UDF Release Webdriver Wiki FAQs 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