Jump to content

Recommended Posts

Posted (edited)

Hi,

I want to click a link by the element ID through IEGetObjById.

<!DOCTYPE html>
<html>
<body>

<button type="button" id="Random-1-ID" onclick="alert('Hello world!')"></button>
 
</body>
</html>

I intend to click the button with ID"Random-1-ID". But on every refresh the ID changes to next number like "Random-2-ID" "Random-3-ID"

 

The code i which i wrote for this function is

#include <IE.au3>
#include <MsgBoxConstants.au3>

Local $oIE = _IECreate("I:\Documents\1. Work\Automation\My codes\Collections\11. Clicking button by Value and ID\button.html")
Local $oDiv = _IEGetObjById($oIE, "Random-1-ID")
_IEAction($oDiv, "click")
_IELoadWait($oIE)

So can anyone help me to alter this code like it clicks for every ID in format "Random-%-ID"

Edited by Paranthaman
Posted

People sleeps sometimes, and works (just like me at the moment).
You must be patience.

Do not bump your thread in 24 Hour from posting questions.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Paranthaman,

you need to be more patient. According to the forum netiquette you need to wait at least 24 hours before bumping a thread.
And do not PM users to help you. That's what the forum is intended for.

We all are volunteers here. So if anyone can help he will. If no one answers then the problem might be too specific and no one knows an answer.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 2/18/2017 at 1:16 PM, Subz said:

Try:

#include <IE.au3>

Local $oIE = _IECreate("http://html.com/input-type-button/", 1)
_IELoadWait($oIE)
Local $oButtons = _IETagNameGetCollection($oIE, "Input")
For $oButton In $oButtons
    If StringLeft($oButton.value, 6) = 'Click ' Then  MsgBox(64, 'Button Found', 'Button found with value: ' & $oButton.value)
    _IEAction($oButton, 'click')
Next

 

Expand  

Thank you so much, it worked :)  . Used StringRight to 3 characters with "-ID" and it clicked . Thanks a lot.

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
×
×
  • Create New...