Jump to content

Recommended Posts

Posted

Hello all,

I need help regarding "_IELinkClickByText"

The HTML Code is:

<span class="ng-binding" ng-bind="::transaction.arrival_time | userDate : ta.data.settings.profile_settings">20160518 01:20:30</span>

In my code i need to click the text (in bold), i keep getting $_IESTATUS_NoMatch.

What am i missing???

Many thanks.

Posted

Please post url to the website or post here a little wider HTML snippet.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

Sorry, i cannot post the url (it requires User Nmae and password)

Attach a text file and pic with some more detailes.

As u see i need to click the first link (20160518 01:20:30) i can get the link but when i am using _IEClickbytext it keeps telling me IE_Status_NOt_Match:'(

I relly aprriciate your help!

 

Element.txt

Capture.JPG

Edited by avidovi
update
Posted

Thanks @Danp2 i did not know that.

I have searched the forum for a solution but it didn't work.

Can u suggest me one?

Thank a lot..

Posted
Local $oClassReturn = $oIE.document.getElementsByClassName("ng-scope")
If Not IsObj($oClassReturn) Then Exit ConsoleWrite("Error in $oClassReturn" & @CRLF)

Local $oTagReturn = $oClassReturn.Item(0).getElementsByTagName("span")
If Not IsObj($oTagReturn) Then Exit ConsoleWrite("Error in $oTagReturn" & @CRLF)

$oTagReturn.Item(0).click()

Hi avidovi,

Without seeing your AutoIT code I can't tell if you're using $oIE as your IE Object handle but if so then try the above code, you may need to increase $oTagReturn.Item(0).click() up by 1 until it corresponds with the correct selection.

Hope this works for you.

Posted

As I stated before show little wider HTML snippet, for example inspect the entire row which was showed in screenshot from post #3.
Of course you can edit, and delete some sensitive data.

 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

@mLipok and @Dent thanks for your help.

I tried Dents option - and i am getting no values at all.

@mLipok as u requested atached the whole row

again thank!!

<tr class="firstline twolines" ng-class="{openmessage: transaction.show_info, twolines: search.layout.rows == 2, oneline: search.layout.rows == 1}"><td><a ui-sref=".details.details({'transactionId':transaction.id})" ng-click="ta.setSelectedTransaction(transaction.id); $event.stopPropagation();" title="UTC+03:00" href="/app/transactions/EDIVAN1-PROD-GEISCO3P252U670001-20160525192046/details"><span ng-bind="::transaction.arrival_time | userDate : ta.data.settings.profile_settings" class="ng-binding">20160526 05:20:46</span></a> <!-- ngIf: search.layout.rows == 1 --> <!-- ngIf: search.layout.rows == 1 && transaction.fa_status --></td><!-- ngRepeat: title in search.layout.first_row --><td ng-repeat="title in search.layout.first_row" ng-show="title.FieldEntry != null" colspan="1" ng-class="{'last-field':$last}" set-field-value="" transaction="transaction" field="title" class="ng-scope ng-isolate-scope ng-hide"><!-- ngIf: title.can_add_to_facet && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngRepeat: label in transaction.values['labels_orig'] track by $index --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><div ng-if="search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 &amp;&amp; title.FieldEntry.IndexFieldName != 'labels'" class="ng-scope"><!-- ngIf: !title.can_add_to_facet && !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20) --><span ng-if="!title.can_add_to_facet &amp;&amp; !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 &amp;&amp; transaction.values[title.FieldEntry.IndexFieldName].length == 20)" ng-bind="::transaction.values[title.FieldEntry.IndexFieldName] " class="ng-binding ng-scope"></span><!-- end ngIf: !title.can_add_to_facet && !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20) --> <!-- ngIf: !title.can_add_to_facet && title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20 --></div><!-- end ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) !== -1 && title.FieldEntry.IndexFieldName != 'labels' --></td><!-- end ngRepeat: title in search.layout.first_row --><td ng-repeat="title in search.layout.first_row" ng-show="title.FieldEntry != null" colspan="1" ng-class="{'last-field':$last}" set-field-value="" transaction="transaction" field="title" class="ng-scope ng-isolate-scope" title="KOHLS"><!-- ngIf: title.can_add_to_facet && title.FieldEntry.IndexFieldName != 'labels' --><a ng-if="title.can_add_to_facet &amp;&amp; title.FieldEntry.IndexFieldName != 'labels'" ng-click="ta.addFilterFromList(transaction, title);$event.stopPropagation();" class="ng-scope"><span ng-bind="::transaction.values[title.FieldEntry.IndexFieldName]" class="ng-binding">KOHLS</span></a><!-- end ngIf: title.can_add_to_facet && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngRepeat: label in transaction.values['labels_orig'] track by $index --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><div ng-if="search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 &amp;&amp; title.FieldEntry.IndexFieldName != 'labels'" class="ng-scope"><!-- ngIf: !title.can_add_to_facet && !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20) --> <!-- ngIf: !title.can_add_to_facet && title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20 --></div><!-- end ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) !== -1 && title.FieldEntry.IndexFieldName != 'labels' --></td><!-- end ngRepeat: title in search.layout.first_row --><td ng-repeat="title in search.layout.first_row" ng-show="title.FieldEntry != null" colspan="1" ng-class="{'last-field':$last}" set-field-value="" transaction="transaction" field="title" class="ng-scope ng-isolate-scope" title="TAA APPAREL"><!-- ngIf: title.can_add_to_facet && title.FieldEntry.IndexFieldName != 'labels' --><a ng-if="title.can_add_to_facet &amp;&amp; title.FieldEntry.IndexFieldName != 'labels'" ng-click="ta.addFilterFromList(transaction, title);$event.stopPropagation();" class="ng-scope"><span ng-bind="::transaction.values[title.FieldEntry.IndexFieldName]" class="ng-binding">TAA APPAREL</span></a><!-- end ngIf: title.can_add_to_facet && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngRepeat: label in transaction.values['labels_orig'] track by $index --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><div ng-if="search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 &amp;&amp; title.FieldEntry.IndexFieldName != 'labels'" class="ng-scope"><!-- ngIf: !title.can_add_to_facet && !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20) --> <!-- ngIf: !title.can_add_to_facet && title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20 --></div><!-- end ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) !== -1 && title.FieldEntry.IndexFieldName != 'labels' --></td><!-- end ngRepeat: title in search.layout.first_row --><td ng-repeat="title in search.layout.first_row" ng-show="title.FieldEntry != null" colspan="1" ng-class="{'last-field':$last}" set-field-value="" transaction="transaction" field="title" class="ng-scope ng-isolate-scope" title="GEISCO3P252U670001-20160525192046"><!-- ngIf: title.can_add_to_facet && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngRepeat: label in transaction.values['labels_orig'] track by $index --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><div ng-if="search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 &amp;&amp; title.FieldEntry.IndexFieldName != 'labels'" class="ng-scope"><!-- ngIf: !title.can_add_to_facet && !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20) --><span ng-if="!title.can_add_to_facet &amp;&amp; !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 &amp;&amp; transaction.values[title.FieldEntry.IndexFieldName].length == 20)" ng-bind="::transaction.values[title.FieldEntry.IndexFieldName] " class="ng-binding ng-scope">GEISCO3P252U670001-20160525192046</span><!-- end ngIf: !title.can_add_to_facet && !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20) --> <!-- ngIf: !title.can_add_to_facet && title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20 --></div><!-- end ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) !== -1 && title.FieldEntry.IndexFieldName != 'labels' --></td><!-- end ngRepeat: title in search.layout.first_row --><td ng-repeat="title in search.layout.first_row" ng-show="title.FieldEntry != null" colspan="1" ng-class="{'last-field':$last}" set-field-value="" transaction="transaction" field="title" class="ng-scope ng-isolate-scope last-field" title="EDI"><!-- ngIf: title.can_add_to_facet && title.FieldEntry.IndexFieldName != 'labels' --><a ng-if="title.can_add_to_facet &amp;&amp; title.FieldEntry.IndexFieldName != 'labels'" ng-click="ta.addFilterFromList(transaction, title);$event.stopPropagation();" class="ng-scope"><span ng-bind="::transaction.values[title.FieldEntry.IndexFieldName]" class="ng-binding">EDI</span></a><!-- end ngIf: title.can_add_to_facet && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngRepeat: label in transaction.values['labels_orig'] track by $index --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><div ng-if="search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 &amp;&amp; title.FieldEntry.IndexFieldName != 'labels'" class="ng-scope"><!-- ngIf: !title.can_add_to_facet && !(title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20) --> <!-- ngIf: !title.can_add_to_facet && title.FieldEntry.IndexFieldName.indexOf('date') > -1 && transaction.values[title.FieldEntry.IndexFieldName].length == 20 --></div><!-- end ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) === -1 && title.FieldEntry.IndexFieldName != 'labels' --><!-- ngIf: search.linkFields.indexOf(title.FieldEntry.IndexFieldName) !== -1 && title.FieldEntry.IndexFieldName != 'labels' --></td><!-- end ngRepeat: title in search.layout.first_row --><td class="quickactions-field" rowspan="2"><!-- ngIf: !transaction.selected --><div ng-if="!transaction.selected" ng-click="ta.openQuickActions(transaction.id, $event)" class="toggle-item-actions ng-scope" data-toggle="dropdown" role="button"><div class="qact-btn"></div></div><!-- end ngIf: !transaction.selected --><!-- ngIf: transaction.selected --></td><td rowspan="2" class="toggle maintoggle pointer" ng-click="search.toggleMoreInfo(transaction);$event.stopPropagation();" ng-class="{active: transaction.show_info}"></td></tr>

 

Posted

Its very hard to help when we can not see the URL (i know that it requires username and password) and the code that you are using to try to click. You could be dealing with frames here, have you check that possibilitie?

From what i can see the span element its inside the "a" element so as the func "_IELinkClickByText" use "outerText" it should grab it. From the html that you have provided i have tested and its working. See if you are dealing with frames and test this:

#include <IE.au3>

Local $oIE = ;******* i dont know if you are using IECreate or IEAttach, just put it here
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oFrames = _IEFrameGetCollection($oIE)
If @error Then
    Exit ConsoleWrite("Error in $oFrames" & @CRLF)
Else
    Local $iNumFrames = @extended
EndIf

MsgBox(0, "", "Nº Frames: " & $iNumFrames)

Local $oFrame = 0
For $i = 0 To ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection($oIE, $i)
    If Not IsObj($oFrame) Or @error Then Exit ConsoleWrite("Error in $oFrame | @error: " & @error & @CRLF)
    
    _IELinkClickByText($oFrame, "20160526 05:20:46", 0, 0) ;*********** make sure the text is equal in the website
    If @error Then
        MsgBox(0, "", "@error: " & @error)
    Else
        Exit MsgBox(0, "Link Found", "Check if the link was clicked")
    EndIf
Next

MsgBox(0, "", "Link Not Found")

Exit

Please pay attention to the commented lines.

Posted

Lets try another code:

#include <IE.au3>

Local $oIE = ;******* i dont know if you are using IECreate or IEAttach, just put it here
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
If Not IsObj($oLinks) Or @error Then Exit ConsoleWrite("Error in $oLinks | @error: " & @error & @CRLF)

ConsoleWrite("Nº of Links: " & $iNumLinks & @CRLF & @CRLF)

For $oLink In $oLinks
    ConsoleWrite("TEXT: " & $oLink.outerText & @CRLF)
    ConsoleWrite("HREF: " & $oLink.href & @CRLF & @CRLF)
Next

ConsoleWrite(@CRLF & "######################################################" & @CRLF & @CRLF& @CRLF)

Local $sHTML = _IEDocReadHTML($oIE)
If @error Then Exit ConsoleWrite("Error in $sHTML")

Local $aLinks = StringRegExp($sHTML, '(?is)<a (.*?)</a>', 3)
If @error Then Exit ConsoleWrite("Error in $aLinks | @error: " & @error & @CRLF)

ConsoleWrite("Nº of Links: " & UBound($aLinks) & @CRLF & @CRLF)

For $i = 0 To UBound($aLinks)-1
    $aResultText  = StringRegExp($aLinks[$i], '>([^<]+)', 3)
    If @error Then Exit ConsoleWrite("Error in $aResultText | $i: " & $i & " | @error: " & @error & @CRLF)
    ConsoleWrite("TEXT: ")
    For $j = 0 To UBound($aResultText)-1
        If Not StringRegExp($aResultText[0], "[A-Za-z0-9]") Then ContinueLoop
        If $j > 0 Then ConsoleWrite(" ")
        ConsoleWrite($aResultText[$j])
    Next
    ConsoleWrite(@CRLF & "HREF: ")

    $aResultHref  = StringRegExp($aLinks[$i], 'href="([^"]+)', 3)
    If @error Then
        ConsoleWrite("0")
        ConsoleWrite(@CRLF & @CRLF)
        ContinueLoop
    EndIf
    For $j = 0 To UBound($aResultHref)-1
        If $j > 0 Then ConsoleWrite(" ")
        ConsoleWrite($aResultHref[$j])
    Next
    ConsoleWrite(@CRLF & @CRLF)
Next

ConsoleWrite(@CRLF & "####### OK #######" & @CRLF)

Exit

I need all the console output.

Posted

Try both codes and let me know the output. Make sure that the current website has the link 20160518 01:20:30 (use Ctrl+f in the website, just to make sure).

#include <IE.au3>

Local $oIE = ;******* i dont know if you are using IECreate or IEAttach, just put it here
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
If Not IsObj($oLinks) Or @error Then Exit ConsoleWrite("Error in $oLinks | @error: " & @error & @CRLF)

ConsoleWrite("Nº of Links: " & $iNumLinks & @CRLF & @CRLF)

Local $sLinkOuterText, $sLinkHref
For $oLink In $oLinks
    $sLinkOuterText = $oLink.outerText
    $sLinkHref = $oLink.href
    ConsoleWrite("TEXT: " & $sLinkOuterText & @CRLF)
    ConsoleWrite("HREF: " & $sLinkHref & @CRLF)
    If $sLinkOuterText = "20160518 01:20:30" Then
        _IEAction($oLink, "click")
        ConsoleWrite("Link found and clicked." & @CRLF)
        Exit
    EndIf
    ConsoleWrite(@CRLF)
Next

Exit
#include <IE.au3>

Local $oIE = ;******* i dont know if you are using IECreate or IEAttach, just put it here
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

_IELinkClickByText($oIE, "20160518 01:20:30")
If @error Then ConsoleWrite("Error n:" & @error & @CRLF)

Exit

 

Posted (edited)
  On 6/1/2016 at 10:59 PM, MichaelHB said:

Try both codes and let me know the output. Make sure that the current website has the link 20160518 01:20:30 (use Ctrl+f in the website, just to make sure).

#include <IE.au3>

Local $oIE = ;******* i dont know if you are using IECreate or IEAttach, just put it here
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended
If Not IsObj($oLinks) Or @error Then Exit ConsoleWrite("Error in $oLinks | @error: " & @error & @CRLF)

ConsoleWrite("Nº of Links: " & $iNumLinks & @CRLF & @CRLF)

Local $sLinkOuterText, $sLinkHref
For $oLink In $oLinks
    $sLinkOuterText = $oLink.outerText
    $sLinkHref = $oLink.href
    ConsoleWrite("TEXT: " & $sLinkOuterText & @CRLF)
    ConsoleWrite("HREF: " & $sLinkHref & @CRLF)
    If $sLinkOuterText = "20160518 01:20:30" Then
        _IEAction($oLink, "click")
        ConsoleWrite("Link found and clicked." & @CRLF)
        Exit
    EndIf
    ConsoleWrite(@CRLF)
Next

Exit
#include <IE.au3>

Local $oIE = ;******* i dont know if you are using IECreate or IEAttach, just put it here
If Not IsObj($oIE) Then Exit ConsoleWrite("Error in $oIE" & @CRLF)

_IELinkClickByText($oIE, "20160518 01:20:30")
If @error Then ConsoleWrite("Error n:" & @error & @CRLF)

Exit

 

Expand  

First thank u!!!

i did not really understand how the link was clicked??  i  did the same thing with _IELinkClickByText but in my script it did not worked.

Can u explain to me please.

attached the first code output.

First code.txt

Edited by avidovi
Posted

The first code basically does the same as the second, was just to make sure that you have not changed the IE UDF code. As i stated before i cant know what was the issue without seeing the code that you were using.

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
×
×
  • Create New...