duzers Posted March 22, 2017 Share Posted March 22, 2017 I try to click button in specific table. site: https://www.supermakler.pkobp.pl/plus/demo/ 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? Link to comment Share on other sites More sharing options...
taylansan Posted March 22, 2017 Share Posted March 22, 2017 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. Link to comment Share on other sites More sharing options...
Subz Posted March 22, 2017 Share Posted March 22, 2017 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 taylansan and duzers 2 Link to comment Share on other sites More sharing options...
duzers Posted March 23, 2017 Author Share Posted March 23, 2017 (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 March 23, 2017 by duzers Link to comment Share on other sites More sharing options...
Subz Posted March 23, 2017 Share Posted March 23, 2017 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" Link to comment Share on other sites More sharing options...
duzers Posted March 23, 2017 Author Share Posted March 23, 2017 (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 March 23, 2017 by duzers Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now