Jump to content

Click element By Text


MJ36
 Share

Recommended Posts

 

Hey, I would need help targeting in learning how to click a diva object, etc. I would like to refer to this text is it possible to refer to text or data words? If so, please help me hint what to read to learn it.

 

 


This is just an example of what I mean :)

 

 

 

 

Edited by MJ36
Link to comment
Share on other sites

All of them will be good for you if you want to "learn" :) 

Also you can try search by keywords in the HelpFile : Search tab.

Or Sumary Tab > User Defined Function > IE Management

_IELinkClickByText

To unswer more to the question. I would suggest you to use the "Class" I would do that with WebDrivers.

I dont really know the syntax with _IE functions but it should work.

 

Anyway if you show us what you tryed, that will allow us to give you more specific help.

Look my avatar ;) 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

#include <IE.au3>

Local $oIE = _IECreate("konsalnet.pl")
_IELoadWait ($oIE)

Local $sMyString = "Wideo weryfikacja alarmów z obiektu i wideo analityka"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

 


ok, I was editing the code above and working. But that's not what I meant exactly :)

In the current situation, autoit clicks on the diva because there is a text in it that is in the link in the div in the case of a diva with a link in which the text does not have a word, the program does not click it.

Link to comment
Share on other sites

If you don't have text then, you need to identify the div, either by name, id or class name attributes, you may even have to select an element before it and use next/previous sibling.

Example:

#include <IE.au3>

Local $oIE = _IECreate("konsalnet.pl", 1)
_IELoadWait ($oIE)
;~ You would normally just use _IEGetObjById($oIE, "contact-form-btn") but just showing how to use h3 collection
Local $oH3s = _IETagNameGetCollection($oIE, "h3")
For $oH3 In $oH3s
    If $oH3.id = "contact-form-btn" Then
        ;~ Get the innertext from the div before the h3 tag
        ConsoleWrite($oH3.PreviousSibling.InnerText & @CRLF)
    EndIf
    ;~ Or you could use class name of the h3 tag as an identifier
    ;~ nb: Class names are generally not recommended unless you know that is the only H3 Tag with that class name.
    If $oH3.ClassName = "formularz-rozwin" Then ExitLoop _IEAction($oH3, "click")
Next

 

Link to comment
Share on other sites

 

@Subz

Thank you for help, I'm beginning to understand it :)

I still have a last question.  If I had a few the same H3 tags with the same class name

$oH3.ClassName = "formularz-rozwin"

Can I somehow give you a hint that the program would click eg in the third same tag ?

 

Link to comment
Share on other sites

First find out what the index number is of the H3 object using the following code:

#include <IE.au3>

Local $oIE = _IECreate("konsalnet.pl", 1)
_IELoadWait ($oIE)
Local $oH3s = _IETagNameGetCollection($oIE, "h3")
For $i = 0 To ($oH3s.Length - 1)
    ConsoleWrite("H3 Tag " & $i & ": " & $oH3s($i).InnerText & @CRLF)
Next

Once you know the index of the object you can use something like:

#include <IE.au3>

Local $oIE = _IECreate("konsalnet.pl", 1)
_IELoadWait ($oIE)
Local $oH3s = _IETagNameGetCollection($oIE, "h3")
Local $oH3 = $oH3s(1) ;~ Formularz kontaktowy H3 tag
_IEAction($oH3, "click")

 

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