Sign in to follow this  
Followers 0
Annonyreeder

Please how can i click this button?

11 posts in this topic

Hello again guys,

Ill try and make this quick as im my brains starting to melt, ive tried aloooot of combinations to try and click the following button, can som1 please just give me a quick few lines that will click the following? Thanks alot guys

<BUTTON class="action af_commandButton" onclick="submitForm('ManageUsers',1,{source:'_id106:_id133'});return false;" type=button>Assign</BUTTON>

 

Thanks again

Ant

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You can list all elements having these classes and click on the first button among this list.

OR: execute directly the submitForm js function (if possible).

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Look into helpfile at examples for _IEAction()

There are two methods of clicking on buttons...

EDIT: Also post what you have tried

Edited by Zedna

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hello, I have tried the followings and nothing seems to work, this comes back positive as i get the Msgbox however it doesnt click the button :S any help apreciated,

thanks.

Also i know there is like 4 or 5 click commands in there that was just where i was trying lot sof different ways of clicking it but none seem to work.

Local $oFound = ""
Local $oBtns = _IETagNameGetCollection($oIE, "button")
For $oBtn In $oBtns
    If String($oBtn.classname) = "action af_commandButton" Then
     $oFound = $oBtn
  _IEAction($oFound, "click")
   EndIf
Next
If IsObj($oFound) Then
 $oFound.fireEvent("onmousedown")
$oFound.fireEvent("onmouseup")
_IEFormSubmit($oIE)
_IEFormSubmit($oFound)
_IEFormSubmit($oBtn)
MsgBox(16, "Success", "SCript works").
Exit
exit
Else
 MsgBox(16, "Failed", "Not found.")
 exit
EndIf
Edited by Annonyreeder

Share this post


Link to post
Share on other sites

Ok i just realised whats happening, it is finding the button however there is about 5 buttons on the same page with the exact same class type.... how can i click the button when the only thing thats different is the "Onclick"?

Share this post


Link to post
Share on other sites

There may be a better way, but have you tried examining the outerHtml property of each button until you find the one containing the desired onClick action?

Share this post


Link to post
Share on other sites

oh thats not the problem, i know which button it is i want to click

<BUTTON class="action af_commandButton" onclick="submitForm('ManageUsers',1,{source:'_id106:_id133'});return false;" type=button>Assign</BUTTON>

 

This is the button i want to click above
And below are the buttons its getting mixed up with

 

<BUTTON id=userProfileForm:Userssave class="action af_commandButton" onclick="submitForm('ManageUsers',1,{source:'userProfileForm:Userssave'});return false;" name=userProfileForm:Userssave type=button>Save</BUTTON>
 
<BUTTON id=userProfileForm:UnassignSingleSelection class="action af_commandButton" onclick="submitForm('ManageUsers',0,{source:'userProfileForm:UnassignSingleSelection'});return false;" name=userProfileForm:UnassignSingleSelection type=button>Unassign</BUTTON>
 
<BUTTON id=userProfileForm:UsersundoAll class="action af_commandButton" onclick="submitForm('ManageUsers',0,{source:'userProfileForm:UsersundoAll'});return false;" name=userProfileForm:UsersundoAll type=button>Cancel</BUTTON>
 
<BUTTON id=usersSubform:Usersinsert class="action af_commandButton" onclick="submitForm('ManageUsers',1,{source:'usersSubform:Usersinsert'});return false;" name=usersSubform:Usersinsert type=button>Create</BUTTON>
 
<BUTTON id=usersSubform:selectButton class="action af_commandButton" onclick="submitForm('ManageUsers',1,{source:'usersSubform:selectButton'});return false;" name=usersSubform:selectButton type=button>Select</BUTTON>
 

 

As you can see they are very different however i just don't know how to direct my script towards the button i need, Ive tried Clicklinkbytext($XX, "Assign"), i had a feeling it wouldn't work as its a button not a link, is there any similar commands to this that would work with a button? ive allso tried changing .Classname to .onclick = "xxx", but also that did not work,

Thanks

Ant

Share this post


Link to post
Share on other sites

You need to be able to programmatically determine the desire button. That was my point... loop through the matching buttons until you find the one with the desired onClick functionality.

I notice that the other buttons each have an assigned ID. You might be able to just search for the one without a value for the ID. Also, you could just look for the button with value of "Assign".

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Ahh ok thanks, but how do i have it loop through checking the onClick, i know how to make it look for Button class but when i change .classname to .onclick it comes up with "nothing found", also when i set it to look for 0 value again nothing is found, examples below

global $oIE
$sUrl = "https://apply.eidverifier.net/uru/connect/SecurityAdmin/ManageUsers.faces"
    $oIE = _IEAttach($sUrl, "url")
$o_form = _IEFormGetObjByName($oIE, "ManageUsers")

$oLinks = _IELinkGetCollection($o_form, 2)
Local $oFound = ""
Local $oBtns = _IETagNameGetCollection($o_form, "Button")
For $oBtn In $oBtns
    If String($oBtn.value) = "" Then
     $oFound = $oBtn
   EndIf
Next
If IsObj($oFound) Then
_IEAction($oFound, "click")
 MsgBox(16, "Success", "Password23 with a captial P (Roles have been set)")
Exit
exit
Else
 MsgBox(16, "Failed", "Not found.")
 exit
EndIf
Local $oFound = ""
Local $oBtns = _IETagNameGetCollection($form5, "Button")
For $oBtn In $oBtns
    If String($oBtn.onclick) = "submitForm('ManageUsers',1,{source:'_id106:_id133'});return false;" Then
     $oFound = $oBtn
   EndIf
Next
If IsObj($oFound) Then
 $oFound.fireEvent("onmousedown")
$oFound.fireEvent("onmouseup")
_IEFormSubmit($oIE)
_IEFormSubmit($oFound)
_IEFormSubmit($oBtn)
 MsgBox(16, "Success", "Password23 with a captial P (Roles have been set)")
Exit
exit
Else
 MsgBox(16, "Failed", "Not found.")
 exit
EndIf

global $oIE
$sUrl = "https://apply.eidverifier.net/uru/connect/SecurityAdmin/ManageUsers.faces"
    $oIE = _IEAttach($sUrl, "url")
$o_form = _IEFormGetObjByName($oIE, "ManageUsers")

$oLinks = _IELinkGetCollection($o_form, 2)
Local $oFound = ""
Local $oBtns = _IETagNameGetCollection($o_form, "Button")
For $oBtn In $oBtns
    If String($oBtn.Value) = "Assign" Then
     $oFound = $oBtn
   EndIf
Next
If IsObj($oFound) Then
_IEAction($oFound, "click")
 MsgBox(16, "Success", "Password23 with a captial P (Roles have been set)")
Exit
exit
Else
 MsgBox(16, "Failed", "Not found.")
 exit
EndIf
 

 

Thanks for help

Ant

Edited by Annonyreeder

Share this post


Link to post
Share on other sites

Use .outerHtml instead of .onClick and then parse the result to identify the desired button.

Did you try this?:

For $oBtn In $oBtns
    If $oBtn.classname = "action af_commandButton" And $oBtn.id = "" Then
        $oFound = $oBtn
        _IEAction($oFound, "click")
        ExitLoop
    EndIf
Next

Share this post


Link to post
Share on other sites

Hey, just relised i forgot to post my results, i did manage to get this working using the following code

$o_form5 = _IEFormGetObjByName($oIE, "ManageUsers")
$valueToSearch="Assign"
$oInputs = _IETagNameGetCollection ($o_form5, "Button")
For $oInput In $oInputs
    $thePropertyValue=$oInput.outerHtml
    If StringInStr($thePropertyValue, $valueToSearch) > 0 Then
        $oInput.FireEvent("onclick")
  endif

 

Thanks for your help on this guys the projects turned out perfect :)

Ant

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
Sign in to follow this  
Followers 0