Jump to content
Hanukka

Code for clicking a button by text not working in IE

Recommended Posts

JLogan3o13

@Hanukka first and foremost, why are you asking a jquery question on an AutoIt forum? :huh2:

Secondly, if you are trying to accomplish this in AutoIt, how about posting what you have tried on your own up to this point? This forum is for assisting people with their own scripts; it is not a place where you put in an order and someone barfs up code for you. 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
water

And BTW:
Please give meaningful titles to your threads. The better you describe your problem in the title the more help you will get. Everyone is looking for a solution on this forum - that's what it is made for ;)
 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Hanukka

Could somebody tell me what is wrong in the code to click the button "run code snippet" in the link mentioned in the code below:-

#include <IE.au3>
$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery')
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
MouseClick("primary", 1358, 697, 15, Default) ;;; Just to reaach to the run code snippet menu
$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If String($oButton.value) = " Run code snippet" Then
       _IEAction($oButton, "click")
    EndIf
Next
Sleep(5000)
_IEQuit($oIE) 

for more convinience the link is:- 'https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery'

It gives no output..BTW i am guessing button.value is wrong,  but then how to choose the button by the text  'Run code snippet' ?

Any help would be appreciated :)

Share this post


Link to post
Share on other sites
Hanukka

Could somebody tell me what is wrong in the code to click the button "run code snippet" in the link mentioned in the code below:-

#include <IE.au3>
$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery')
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
MouseClick("primary", 1358, 697, 15, Default) ;;; Just to reaach to the run code snippet menu
$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If String($oButton.value) = " Run code snippet" Then
       _IEAction($oButton, "click")
    EndIf
Next
Sleep(5000)
_IEQuit($oIE) 

for more convinience the link is:- 'https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery'

It gives no output..BTW i am guessing button.value is wrong,  but then how to choose the button by the text  'Run code snippet' ?

Any help would be appreciated :)

Share this post


Link to post
Share on other sites
Hanukka

@JLogan3o13..chill bruh. I didnot post my code cuz i couldnt do shit in it..btw here it is:

#include <IE.au3>
$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery')
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
$frame = _IEFrameGetObjByName($oIE, 'a3370ed0-a917-e85c-938a-c1d8c4aa8673');;;;Can't even get this frame :s
Sleep(5000)
_IEQuit($oIE)

The output is shown as ' --> IE.au3 T3.0-2 Warning from function _IEFrameGetObjByName, $_IESTATUS_NoMatch (No frames matching name) '

I guess i havent yet understood the right way of accessing frames..can somebody pls help

Also i guess this is very much an autoit question..I dont know if there is a method to solve this using jquery.

@water..sure man...could you please help me out with this?

I guess the frame name gets dynamically created...If so, how to make it work with that??

Edited by Hanukka

Share this post


Link to post
Share on other sites
water

I won't be of much help as I do not work with the IE UDF :(


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Subz
#include <IE.au3>
$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery', 1)
_IELoadWait($oIE)
$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If String($oButton.innertext) = " Run code snippet" Then
       _IEAction($oButton, "click")
    EndIf
Next

 

  • Like 1

Share this post


Link to post
Share on other sites
JLogan3o13

@Hanukka stick to one topic from now on, please. Threads merged.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Hanukka

@Subzero....so it was 'inner text'...Thanks a lot bruh!!

On 6/6/2017 at 7:11 PM, Hanukka said:

want to check the checkbox in the frame which pops up after choosing "run code snippet" option. ( Internet Explorer one would be prefered )

Can somebody also help me with this??.....The frame the checkbox is in gets dynamically created, so i dont know how to access the frame itself.

And @JLogan3o13..dude pls help me out with my doubts rather than ordering them and all.

Share this post


Link to post
Share on other sites
JLogan3o13
7 hours ago, Hanukka said:

And @JLogan3o13..dude pls help me out with my doubts rather than ordering them and all.

You are getting help, but you also need to follow the rules of the forum. Posting your question multiple times makes it more difficult for people trying to help you..."bruh"

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Hanukka

@Danp2..Alright mate..i've tried this..pls have a look:-

#include <IE.au3>
$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery', 1)
_IELoadWait($oIE)
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
$oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/(10)) ;;;get to the button area
$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If String($oButton.innertext) = " Run code snippet" Then
       _IEAction($oButton, "click")
    EndIf
Next
$oFrame = _IEFrameGetCollection($oIE, 0) ;;It is the first frame itself
$input = _IEGetObjById($oFrame, 'isAgeSelected')  ;; The id of the input check box in it
;_IEAction($input, 'click') ;;;gives an error in the previous statement only!!!!!

The error it throws is:

 ==> The requested action with this object has failed.:

If IsObj($oObject.document.getElementById($sID)) Then
If IsObj($oObject^ ERROR

* Also those stack overflow ppl haven't provided <form> tags...which makes me really confused

pls help @water, @Subz..o:)

And @JLogan3o13...cool bruh.. ill follow them rulzz

Edited by Hanukka

Share this post


Link to post
Share on other sites
MattHiggs
1 hour ago, Hanukka said:

@Danp2..Alright mate..i've tried this..pls have a look:-

#include <IE.au3>
$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery', 1)
_IELoadWait($oIE)
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
$oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/(10)) ;;;get to the button area
$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If String($oButton.innertext) = " Run code snippet" Then
       _IEAction($oButton, "click")
    EndIf
Next
$oFrame = _IEFrameGetCollection($oIE, 0) ;;It is the first frame itself
$input = _IEGetObjById($oFrame, 'isAgeSelected')  ;; The id of the input check box in it
;_IEAction($input, 'click') ;;;gives an error in the previous statement only!!!!!

The error it throws is:

 ==> The requested action with this object has failed.:

If IsObj($oObject.document.getElementById($sID)) Then
If IsObj($oObject^ ERROR

* Also thosestack overflow ppl haven't provided <form> tags...which makes me really confused

pls help @water, @Subz..o:)

And @JLogan3o13...cool bruh.. ill follow themrulzz

1 hour ago, Hanukka said:

@Danp2..Alright mate..i've tried this..pls have a look:-

#include <IE.au3>
$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery', 1)
_IELoadWait($oIE)
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
$oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/(10)) ;;;get to the button area
$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If String($oButton.innertext) = " Run code snippet" Then
       _IEAction($oButton, "click")
    EndIf
Next
$oFrame = _IEFrameGetCollection($oIE, 0) ;;It is the first frame itself
$input = _IEGetObjById($oFrame, 'isAgeSelected')  ;; The id of the input check box in it
;_IEAction($input, 'click') ;;;gives an error in the previous statement only!!!!!

The error it throws is:

 ==> The requested action with this object has failed.:

If IsObj($oObject.document.getElementById($sID)) Then
If IsObj($oObject^ ERROR

* Also thosestack overflow ppl haven't provided <form> tags...which makes me really confused

pls help @water, @Subz..o:)

And @JLogan3o13...cool bruh.. ill follow themrulzz

Hm.  This may be a bit more difficult than initially thought.  Here is the info for the button you want to click:

vwHBTrm.png

No name or ID property.  You may have to reference it by index....

  • Like 1

Share this post


Link to post
Share on other sites
anthonyjr2

The problem seems to be that the checkbox is inside an iframe, and for some reason I can't seem to get it to recognize the frame as an object. I can't call _IEGetObjByID on the frame. I'm not sure if it's a problem with newer versions of IE or the UDF...


UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites
anthonyjr2

Alright, I've worked out that this is an issue with the iFrames on stackoverflow. You will get an Access Denied error like so:

err.number is:      0x80020009
    err.windescription: Exception occurred.

    err.description is:     Access is denied.

    err.source is:      
    err.helpfile is:    C:\Windows\System32\mshtml.hlp
    err.helpcontext is:     0
    err.lastdllerror is:    0
    err.scriptline is:  1899
    err.retcode is:     0x80070005

if you try to access the elements in the iframe. Apparently this is due to an XSS restriction, the iframe might be hosted on another url, but I can't find the link anywhere.

Here's my code in case someone else wants to give it a shot:

#AutoIt3Wrapper_UseX64=Y
#include <IE.au3>

_IEErrorHandlerRegister(_User_ErrFunc)

$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery', 0)
_IELoadWait($oIE)
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
$oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/(10)) ;;;get to the button area
$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If String($oButton.innertext) = " Run code snippet" Then
       _IEAction($oButton, "click")
    EndIf
Next

Sleep(2000)
$oIE = _IEAttach("Stack Overflow")
$oFrames = _IEFrameGetCollection($oIE) ;It is the first frame itself
$iLength = $oFrames.length
;MsgBox(64, "Test", ".length = " & $iLength)

Local $checkBox
Local $oFrame

For $i=0 To $iLength-1
    $oFrame = _IEFrameGetCollection($oIE, $i)
    If @error Then
        MsgBox(0, "d", @error)
    EndIf
    If(IsObj($oFrame)) Then
        If (_IEGetObjById($oFrame, "isAgeSelected")) Then
            If Not $checkBox.checked Then
                $checkBox.checked = True
            EndIf
            ExitLoop
        EndIf
    EndIf
Next

;_IEAction($input, "click") ;;;gives an error in the previous statement only!!!!!

; User's COM error function.
; After SetUp with ObjEvent("AutoIt.Error", ....) will be called if COM error occurs
Func _User_ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptFullPath & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
            @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
            @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
            @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
            @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc   ;==>_User_ErrFunc

It fails on the line "If (_IEGetObjById($oFrame, "isAgeSelected")) Then"

  • Like 1

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites
Hanukka

Thanks for helping out guys...although the solution couldnt be reached..I don't have enough knowledge about this to work on it, but is it possible to get this under the spotlight?..Like to the folks who have contributed to the IE UDFs??

But I still wonder that why would a site like stack overflow, itself using https protocol, have a XSS restriction? :blink:

 ✌️

^ Also the code fails on both IE8 and IE11

Edited by Hanukka

Share this post


Link to post
Share on other sites
Hanukka
16 hours ago, MattHiggs said:

Hm.  This may be a bit more difficult than initially thought.  Here is the info for the button you want to click:

vwHBTrm.png

No name or ID property.  You may have to reference it by index....

Bro...the button worked fine, the problem was that the next frame which pops up after clicking it, which has the checkbox, that I am unable to access...the button can be clicked by index and also by innerText as mentioned by @Subz

Share this post


Link to post
Share on other sites
anthonyjr2
On 6/9/2017 at 1:13 AM, Hanukka said:

Thanks for helping out guys...although the solution couldnt be reached..I don't have enough knowledge about this to work on it, but is it possible to get this under the spotlight?..Like to the folks who have contributed to the IE UDFs??

But I still wonder that why would a site like stack overflow, itself using https protocol, have a XSS restriction? :blink:

 ✌️

^ Also the code fails on both IE8 and IE11

This isn't a limitation of the UDF or the website, it's a limitation of all browsers in general. They purposely deny XSS for security reasons.

  • Like 1

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Share this post


Link to post
Share on other sites
Hanukka

Guys, I gave it a bit of sleep time, since some frames get dynamically created n i thought that the script ran before the frame was created. The frame creation gave no error but I am still not able to access the inner check box. Pls have a look at the code:-

#include <IE.au3>
$oIE = _IECreate('https://stackoverflow.com/questions/901712/how-to-check-whether-a-checkbox-is-checked-in-jquery', 1)
_IELoadWait($oIE)
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)
$oIE.document.parentwindow.scroll(0, $oIE.document.body.scrollHeight/(10))
$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If String($oButton.innertext) = " Run code snippet" Then
       _IEAction($oButton, "click")
    EndIf
 Next
 Sleep(5000)
$oframe = _IEFrameGetCollection($oIE, 0) ;The first frame
;MsgBox(0, "", @error) ; error flag is 0
Sleep(2000)
$tag = _IETagNameGetCollection($oframe, 'input', 0) ; The first checkbox input tag
;_IEAction($tag, 'click') ; checks the checkbox

 

It gave a new error this time, which again is mandarin to me :(

 ==> The requested action with this object has failed.:

Return SetError($_IESTATUS_Success, 0, $oObject.document)
Return SetError($_IESTATUS_Success, 0, $oObject^ ERROR

@anthonyjr2...still the same XSS problem leading to this, mate??

 

Share this post


Link to post
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

  • Similar Content

    • BogdanNicolescu
      By BogdanNicolescu
      While 1 / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / WEnd OR:

       
      HotKeySet("{ESC}", "Terminate") While 1 MouseClick("Right",674,422) MouseClick("Left",673,447) Sleep(2000) / / / A whole bunch of codes found in help and here: https://www.autoitscript.com/autoit3/docs/ / / / MouseClick("Left",675,339) SLeep(3000) WEnd Func Terminate()     Exit 0 EndFunc  
      Sorry if i should't let this here to be found by newbies like me -.-'
    • santoshM
      By santoshM
      Dear friends i am facing a problem , i have created a window in autoit some time it is moving with the mouse curser even if iam not clicking the window 
    • sumanth1980
      By sumanth1980
      Here i am wrote a simple lines to install basic applications but when i clicked on one application/program to install it was working fine but when i cancel the program in the middle to install another program it was not working. I am not an expert in this but i want a solution for this ... Can any one help me on this....
      ORG-1.au3
    • PleaseHelpMEIWillLoveyou
      By PleaseHelpMEIWillLoveyou
      Is there a way to use a custom terminal or something from my pc and run a script on another pc.
      please let me know if its possible
      (not for anything bad just for a project im working on)
    • juniq
      By juniq
      Hey I'm writing on a script which places a link in the context menu so you can choose several mp3 files and rename them using id3 tag udf and year / time stuff variables.
      My problem: I'm renaming the files through "FileMove", But HOW can I get the current directory of the chosen files only? I can't use stringsplit cz there are more than 1 delimiter "\". and I can't trim the string because the stringlength changes every time. How can I get ONLY the directory where the files from $cmdline chosen are? 
×