Jump to content

Script not able to click on button type


Recommended Posts

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

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.

Link to comment
Share on other sites

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! :lol:

Link to comment
Share on other sites

   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

$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

$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

<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

@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.

Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...