duzers

IE.au3 Click button in specifc table.

6 posts in this topic

#1 ·  Posted

I try to click button in specific table.

site: https://www.supermakler.pkobp.pl/plus/demo/

2017-03-22_17-25-44.jpg

There is a refresh button with class name ".....x-tool-refresh...." but this name is in all tables. I have to click only this button without using ID (becouse ID is sometimes  changed).

Any idea?

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

The ID didn't change while I was trying. And there are three refresh buttons in your page. Third refresh button is the one in the Zlecnia (don't know what it means). 

#include <IE.au3>
#include <Array.au3>

Local $aRefreshButtons[0] ;there are three refresh buttons in your page
$oIE = _IECreate("https://www.supermakler.pkobp.pl/plus/demo/")
_IELoadWait($oIE)

$oDivs = _IETagNameGetCollection($oIE, "div")
For $oDiv In $oDivs
    If $oDiv.id <> "" And $oDiv.classname = " x-nodrag x-tool-refresh x-tool epm-toolButton x-component " Then
        ConsoleWrite($oDiv.id & " - " & $oDiv.className & @CRLF)
        _ArrayAdd($aRefreshButtons, $oDiv.id)
    EndIf
Next
_ArrayDisplay($aRefreshButtons)

$oRefreshButton = _IEGetObjById($oIE, $aRefreshButtons[2]) ;your refresh button is always the third
_IEAction($oRefreshButton, "focus")
If _IEAction($oRefreshButton, "click") Then
    ConsoleWrite("OK" & @CRLF)
    _IELoadWait($oIE)
Else
    ConsoleWrite("NOK" & @CRLF)
EndIf

;_IEQuit($oIE)

I'm sure there is a better way to solve this and I would learn the easier way too. 


TY.

Share this post


Link to post
Share on other sites

#3 ·  Posted

Another method:

#include <IE.au3>
$oIE = _IECreate("https://www.supermakler.pkobp.pl/plus/demo/", 1)
$oDivs1 = _IETagNameGetCollection($oIE, "Div")
For $oDiv1 In $oDivs1
    If StringInStr($oDiv1.id, "x-auto-") Then
        If StringStripWS($oDiv1.innertext, 8) = "Zlecenia" Then
            $oDivs2 = _IETagNameGetCollection($oDiv1, "Div")
            For $oDiv2 In $oDivs2
                If StringStripWS($oDiv2.ClassName, 7) = "x-nodrag x-tool-refresh x-tool epm-toolButton x-component" Then
                    _IEAction($oDiv2, "Click")
                EndIf
            Next
        EndIf
    EndIf
Next

 

2 people like this

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

$nextstep = False
$oDivs1 = _IETagNameGetCollection($oIE, "Div")
For $oDiv1 In $oDivs1
    If StringInStr($oDiv1.classname, "epm-gadget-panel-edge-center") And StringStripWS($oDiv1.innertext, 8) == "Zlecenia" Then
        $nextstep = True
    EndIf

    If $nextstep == True And StringInStr($oDiv1.classname, "x-tool-refresh") Then
        _IEAction($oDiv1, "Click")
        $nextstep = False ;There are two "Zlecenia"
    EndIf
Next

There are two panes "Zlecenia" in tabs "Stan rachunku" and "Zlecenia", and I didn't use breakloop after first Click.

 

Edited by duzers

Share this post


Link to post
Share on other sites

#5 ·  Posted

Isn't the other named "Zlecenia Online"?  If you wanted to target this you would need to use:
Note, flag 7 removes beginning and end spaces + double spaces.  flag 8 removes all white space.  Also you can use single = if you aren't worried about string case, otherwise == to match the string exactly.

StringStripWS($oDiv1.innertext, 7) = "Zlecenia Online"

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yes, there is "Zlecenia Online" but in the same tab. I used exactly comparison and it skipped "Zlecenia Online". Another "Zlecenia" is in tab "Stan rachunku" (look at the top of site). My code refresh all panes named "Zlecenia" but offcourse I can first check if it is in specific Tab.

Edited by duzers

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