Jump to content

[Solved] Simulating IE click on complex "A" tagg


Recommended Posts

Hi

Am trying to simulate a click on this "thing". Can't really know how to handle it

<a name="viewr.alm_hardware.managed_by" tabindex="-1" class="btn btn-default btn-ref icon icon-info" id="viewr.alm_hardware.managed_by" data-type="reference_popup" data-ref="alm_hardware.managed_by" data-table="alm_hardware" data-ref-key="null" data-new-window="false" data-view="" data-form="sys_user.do"><span class="sr-only">Preview record for field: Géré par</span></a>

It is a button that open a Window of another form

Allreayd tried to get collection of all types, getting ObjByName or ID, unsuccessully

 

Any idea ?

Edited by Ebola57
Link to comment
Share on other sites

I allready tried  _IELinkClickByText but as there's no HREF I don't really know what to search for

If I try _IEGetObjByName , no Obj returned

In fact this code is behind a img button in a ServiceNow session

Edited by Ebola57
Link to comment
Share on other sites

Going to provide more :)

As joined, that is the screenshot of the button I want to interract

I succesfully cath any other information from this frame (INPUT) with such code

Local $oForm = _IEFormGetObjByName($oFrame,"alm_hardware.do")
Local $oElem = _IEFormElementGetObjByName($oForm,"sys_display.original.alm_hardware.managed_by")
Local $Res = _IEFormElementGetValue($oElem)
Return $Res

This code catch the content of the INPUT just right next to, and works flawelessly

<input name="sys_display.alm_hardware.managed_by" class="form-control element_reference_input  " id="sys_display.alm_hardware.managed_by" role="combobox" aria-required="false" aria-labelledby="label.alm_hardware.managed_by" aria-activedescendant="" aria-owns="AC.alm_hardware.managed_by" spellcheck="false" aria-autocomplete="list" onfocus="if (!this.ac) addLoadEvent(function() {var e = gel('sys_display.alm_hardware.managed_by'); if (!e.ac) new AJAXTableCompleter(gel('sys_display.alm_hardware.managed_by'), 'alm_hardware.managed_by', 'null', ''); e.ac.onFocus();})" type="text" value="TOTO" data-name="managed_by" autocomplete="off" data-type="ac_reference_input" data-ref="alm_hardware.managed_by" data-table="sys_user" data-ref-dynamic="false" data-ref-key="null" data-ref-qual="" data-dependent="null" data-completer="AJAXTableCompleter" ac_order_by="last_name" ac_columns="first_name;last_name;user_name;email" autocorrect="off">

 

Actually I interract with this button with graphic method, that is not 100% reliable

screen.png

Link to comment
Share on other sites

The code I posted catch the INPUT value, works fine

The code I need is : Go click on the 'info' button I enlighted
So Indeed thet don't have the same name and/or id

Going to post some code that  doesn't work

Link to comment
Share on other sites

$oForm = _IEFormGetObjByName($oIE,0)
$oTag = _IEFormElementGetObjByName($oForm,"viewr.alm_hardware.managed_by")
_IEAction($oTag,"click")

Returns

--> IE.au3 T3.0-2 Warning from function _IEFormElementGetObjByName, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType

In fact, I have problems because there's no simpole function that handle the "A' tag that has no HREF nor anything 'regular'

I can catch INPUT, TABKE, or BUTTON easily but this 'A' turns me nut

 

 

Edited by Ebola57
Link to comment
Share on other sites

3 minutes ago, Danp2 said:

Previously, you retrieved the form by name instead of index. Are you sure that you have the correct form?

Yes this 'A' tag is from the form "alm_hardware.do"

As i said INPUT tag is'nt a problem at all, only this 'A' tag

If I try to get a collection of all 'A' tagg, I never get the name of this one

Edited by Ebola57
Link to comment
Share on other sites

2 minutes ago, Ebola57 said:

Yes this 'A' tag is from the form "alm_hardware.do" 

As i said INPUT tag is'nt a problem at all, only this 'A' tag

I'm trying to help you, but you have me at a distinct disadvantage because I can't see the website's full HTML. You're telling me that it's the same form, but you're using a different method to retrieve the form's object reference.

Instead of this --

$oForm = _IEFormGetObjByName($oIE,0)

please use this --

$oForm = _IEFormGetObjByName($oFrame,"alm_hardware.do")

In fact, now I'm wondering if you meant to use _IEFormGetCollection here instead of _IEFormGetObjByName because it doesn't make sense to pass a value of 0 for the form's name.

Also, just notice the use of $oFrame instead of the traditional $oIE. You didn't show how this variable was defined. Is this truly a frame reference? If so, shouldn't you be using it as well when trying to click the link?

Link to comment
Share on other sites

In first intention I intended to catch all the 'A' tagg. It somehow works for some of

Example :

Local $oTags = _IETagNameGetCollection($oIE, "a")
For $oTag In $oTags
    ConsoleWrite("Id:" & $oTag.id & @TAB & "Name:" & $oTag.name & @CRLF)
Next

Returns Id:print-icon Name:

And in source code it appears as

<a class="icon-print settings-menu-icon" id="print-icon" href="javascript:void(0)"><span class="sr-only">Version imprimable</span></a>

But at no moment I catch the 'A' tag from

<a name="viewr.alm_hardware.managed_by" tabindex="-1" class="btn btn-default btn-ref icon icon-info" id="viewr.alm_hardware.managed_by" data-type="reference_popup" data-ref="alm_hardware.managed_by" data-table="alm_hardware" data-ref-key="null" data-new-window="false" data-view="" data-form="sys_user.do"><span class="sr-only">Preview record for field: Géré par</span></a>

Why ? :( It has an id, but no link as it opens a window with data from another form

Link to comment
Share on other sites

5 minutes ago, Danp2 said:

Probably because it's contained in a frame. First, get a reference to the frame. Then use that in place of $oIE in your code above.

Going to check this en ensure that I work on the right one

There is indeed frames

Stay tuned dear helper :)

Link to comment
Share on other sites

You were ****ly right

I wrote this code

Local $oFrame = _IEFrameGetCollection($oIE,0)
Local $oTags = _IETagNameGetCollection($oFrame, "a")
For $oTag In $oTags
    ConsoleWrite("Id:" & $oTag.id & @TAB & @TAB & @TAB & "Classname:" & $oTag.className & @TAB & @TAB & @TAB & "Name:" & $oTag.name & @CRLF)
Next

And in the flood result appears

Id:viewr.alm_hardware.managed_by   Classname:btn btn-default btn-ref icon icon-info   Name:viewr.alm_hardware.managed_by

Going to replace the Consolewrite with some action now

Link to comment
Share on other sites

You ARE my god ! I Got it

$oFrame = _IEFrameGetCollection($oIE,0)
Local $oTags = _IETagNameGetCollection($oFrame, "a")
For $oTag In $oTags
    If $oTag.id == "viewr.alm_hardware.managed_by" Then _IEAction($oTag, "click")
Next

Successfully clicked on the icon I wanted :D

Many, many thanks !

Link to comment
Share on other sites

8 minutes ago, Danp2 said:

Glad you got it working (Finally! 😝) . You should be able to simply this code by using _IEGetObjById instead of _IETagNameGetCollection and the For...Next.

For sure :)

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