Jump to content

How to click on the button ("innertext") with text?


Rei10
 Share

Recommended Posts

#include <IE.au3>
Opt("TrayIconDebug",1)
$sUrl = 'https://moskva.beeline.ru/customers/products/mobile/services/archive/'

$oIE = _IECreate ($sUrl)
_IELoadWait($oIE);
$Links=_IELinkGetCollection($oIE)
for $Link in $Links
if _IEPropertyGet($Link,"innertext")=="Отправляй сообщения" then
$Link.click
exitloop
endif
next
Exit

;-------------------------or
#include <IE.au3>

$oIE = _IECreate("https://moskva.beeline.ru/customers/products/mobile/services/archive/")
$oInputs = _IETagNameGetCollection($oIE, "data-url")
For $oInput In $oInputs
   If $oInput.ClassName == "/complexwidget/getwidget/?itemId=466660&ui-page=426824&ui-part=466650&ui-culture=ru-ru&ui-region=moskva" Then
      _IEAction($oInput, "click")
      _IELoadWait($oIE)
      EndIf
   Next

 

Link to comment
Share on other sites

Couldn't get my system to recognise the innertext, even though the script is encoded with unicode, however the following works:

#include <IE.au3>
Opt("TrayIconDebug",1)
$sUrl = 'https://moskva.beeline.ru/customers/products/mobile/services/archive/'

Local $oIE = _IECreate ($sUrl, 1)
_IELoadWait($oIE)
Sleep(3000)
Local $oSpans=_IETagNameGetCollection($oIE, "span")
For $oSpan In $oSpans
    If $oSpan.getAttribute("data-url") = "/complexwidget/getwidget/?itemId=466660&ui-page=426824&ui-part=466650&ui-culture=ru-ru&ui-region=moskva" Then
        _IEAction($oSpan, "click")
        ExitLoop
    EndIf
Next

 

Link to comment
Share on other sites

Subz, many thanks. I search all day on the Internet.

The last thing I managed to find.

#include <IE.au3>
Do
    $oIE = _IECreate('https://moskva.beeline.ru/customers/products/mobile/services/archive/')
    $oLinks = _IETagNameGetCollection($oIE, 'data-url')
    If @error Then ExitLoop
    For $oLink In $oLinks
        If $oLink.ClassName == '/complexwidget/getwidget/?itemId=466660&ui-page=426824&ui-part=466650&ui-culture=ru-ru&ui-region=moskva' Then
            ConsoleWrite($oLink.href & @LF)
            _IEAction($oLink, 'focus')
            ConsoleWrite('focus: ' & @error & @LF)
            _IEAction($oLink, 'click')
            ConsoleWrite('click: ' & @error & @LF)
            _IELoadWait($oIE)
            ExitLoop
        EndIf
    Next
Until 1

Subz, happy new year.

Edited by Rei10
Link to comment
Share on other sites

np: just couple of things

_IETagNameGetCollection is referring to the <tag /> for example <span ...>, <div ...>, <td ...> etc...

.className is referring to css class i.e. <tag class="className" /> for example <span class="dynamic complex-widget-link" ...>
nb: The issue with className is that classes can be used multiple times within a document so they aren't reliable.

data-url is refered to as an attribute.

Also discovered how you can use innerText, forgot to strip leading/trailing whitespace, see example below:

#include <IE.au3>
Opt("TrayIconDebug",1)
Local $sUrl = 'https://moskva.beeline.ru/customers/products/mobile/services/archive/'

Local $oIE = _IECreate ($sUrl, 1)
_IELoadWait($oIE)
Sleep(3000)
Local $oSpans=_IETagNameGetCollection($oIE, "span")
For $oSpan in $oSpans
    ;~ Stip leading/trailing whitespace
    If StringStripWS($oSpan.innerText, 3) = "Отправляй сообщения" Then
        _IEAction($oSpan, "click")
        Exitloop
    Endif
Next

 

Link to comment
Share on other sites

  • 2 weeks later...
  • Developers

It looks like you are trying to bypass a Captcha security prompt right?
Ensure you read our forum rules about that not being allowed to be discussed in our forums!

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

"holding me" ?

I guess something got lost in translation here!....  but I do see you removed the attached code!

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

15 minutes ago, Rei10 said:

I will try to rephrase the question so as not to violate your rules.

To violate the forum rules, it does not necessarily depend on the phrasing of the question.

It also depends on what intentions are behind the question (at least if they are obvious) ;).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • Developers
21 minutes ago, Rei10 said:

I will try to rephrase the question so as not to violate your rules.

That is a violation of our rules too:

Quote

7. Do not repost the same question if the previous thread has been locked - particularly if you merely reword the question to get around one of the prohibitions listed above.

*click*

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...