Click on Webpage button not having ID

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
abj
Posts: 8
Joined: 24 Jul 2021, 08:24

Click on Webpage button not having ID

26 Jul 2021, 06:23

How to click on this button using Internet Explorer DOM. This does not have ID and I do not have IT background.

<button class="btn btn-primary pad-l-50 pad-r-50" onclick="location.href='//return.gst.gov.in/returns/auth/dashboard'" type="button"><span title="Return Dashboard">Return Dashboard</span> <i class="fa fa-angle-right"></i></button>

Please guys also check my previous post which has gone unanswered as on date.
Much appreciated!
User avatar
boiler
Posts: 16923
Joined: 21 Dec 2014, 02:44

Re: Click on Webpage button not having ID

26 Jul 2021, 06:43

Try something like:

Code: Select all

wb.document.getElememtsByClassName("btn btn-primary pad-l-50 pad-r-50")[0].Click()

The 0 might need to be changed to something else if there are multiple buttons with that class name. The one with 0 would be the first.
User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Click on Webpage button not having ID

26 Jul 2021, 06:47

You can use getElementsByTagName("button") and you get whole range of buttons if page has only one button you can click on it by doing getElementsByTagName("button")[0].click() same thing you can perform using getElementsByClassName, doing getElementsByTagName("button")[0].innerText will get you the innerText and you can now loop through innerText and when innerText matched make your code click on that element

following code doing above stuff using while loop

Code: Select all

While ( wb.document.getElementsByTagName("button")[ A_Index - 1].InnerText != "Return Dashboard" )
	i := A_Index
wb.document.getElementsByTagName("button")[ i ].click()
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, dangoscrub, doodles333, joedf, Nerafius and 129 guests