Jump to content

How to click on a website button (with no name)?


Recommended Posts

Hello everyone,

I want to find the "name" of a button on a wesbite so I can make bot which clicks on the button.

In Chrome I used the "inspect"-tool to find the name but all I got is this:

 

<button class="btn btn-block btn-primary btn-lg" type="submit" id="btn-add-to-cart" data-original-title="" title="">
<i class="fa fa-check"></i>

" Anmelden
                                        
                                    "
</button>

My Code so far (which didnt work):

Global $oIE = _IECreate ("https:xxx")
Local $button2 = _IEGetObjByName ($oIE,"btn-add-to-cart.btn.btn-block.btn-primary.btn-lg")
_IEAction ($button2,"click")

 

Can anyone help?

Link to comment
Share on other sites

Every function in AutoIt returns some type of error indication if something goes wrong.
_IE* functions set @error to > 0.
Can you please add some debugging code to your script?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks for the fast answer!

Here the error:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\franz\Documents\AutoIT\Test2.au3"    
--> IE.au3 T3.0-2 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: btn-add-to-cart.btn.btn-block.btn-primary.btn-lg, Index: 0)
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType
>Exit code: 0
Link to comment
Share on other sites

Hello again,

I got another problem: on the next page I want to type something in the four boxes ("Vorname", "Nachname", Benutzungsausweisnummer", "Telefonnummer", see attached picture). But for all four of them I get the same (only the placeholder is different):

<input name="4383716-question_11864" title="" class="form-control" id="id_4383716-question_11864" required="" type="text" placeholder="Vorname" data-dpmaxz-eid="3">

Any ideas how to start?

grafik.png

Link to comment
Share on other sites

That's not enough details for us to accurately answer your question. At a minimum, you should show us the HTML for all four element, plus any associated form.

P.S. If there's an associated form, then you may be able to use _IEFormElementGetCollection with an appropriate $iIndex value to retrieve each element. There's also an $iIndex parameter for _IEGetObjByName

Link to comment
Share on other sites

Franz135,

can you please tell us why you need to automate a login to a website ("Anmelden")?
And why do you need to automate the input of a security means like the "Benutzungsausweisnummer" ("ID card number")?

Last but not least: Are you sure bypassing security means is in line with the Terms Of Use of the site?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Here the html (they seem pretty similiar):

PS: How can I find an associated form?

<input type="text" name="4384694-question_11864" class="form-control" placeholder="Vorname" title="" required="" id="id_4384694-question_11864">

<input type="text" name="4384694-question_11865" class="form-control" placeholder="Nachname" title="" required="" id="id_4384694-question_11865">

<input type="text" name="4384694-question_11683" class="form-control" placeholder="Benutzungsausweisnummer" title="" required="" id="id_4384694-question_11683">

<input type="text" name="4384694-question_11684" class="form-control" placeholder="Telefonnummer" title="" required="" id="id_4384694-question_11684">

all four togehter:
<div class="panel-body questions-form" data-idx="0">
                            
<div class="form-group required"><label class="col-md-3 control-label" for="id_4384694-question_11864">Vorname</label>

<div class="col-md-9"><input type="text" name="4384694-question_11864" class="form-control" placeholder="Vorname" title="" required="" id="id_4384694-question_11864"></div></div>
<div class="form-group required"><label class="col-md-3 control-label" for="id_4384694-question_11865">Nachname</label><div class="col-md-9"><input type="text" name="4384694-question_11865" class="form-control" placeholder="Nachname" title="" required="" id="id_4384694-question_11865"></div></div>
<div class="form-group required"><label class="col-md-3 control-label" for="id_4384694-question_11683">Benutzungsausweisnummer</label><div class="col-md-9"><input type="text" name="4384694-question_11683" class="form-control" placeholder="Benutzungsausweisnummer" title="" required="" id="id_4384694-question_11683"></div></div>
<div class="form-group required"><label class="col-md-3 control-label" for="id_4384694-question_11684">Telefonnummer</label><div class="col-md-9"><input type="text" name="4384694-question_11684" class="form-control" placeholder="Telefonnummer" title="" required="" id="id_4384694-question_11684"></div></div>
                            
                        </div>
Link to comment
Share on other sites

2 minutes ago, Danp2 said:

So this turned out to be incorrect. Looking at the HTML you posted above, each element has it's own unique name and ID.

So that seems to be the problem? 🤔

You are right, I didnt see it. Thanks!

Edited by Franz135
Link to comment
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
 Share

  • Recently Browsing   0 members

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