Franz135 Posted July 28, 2020 Share Posted July 28, 2020 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 More sharing options...
Danp2 Posted July 28, 2020 Share Posted July 28, 2020 Can't tell from the limited details you've supplied, but you can probably use _IEFormSubmit if this buttton is associated with a form. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
water Posted July 28, 2020 Share Posted July 28, 2020 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? Franz135 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Danp2 Posted July 28, 2020 Share Posted July 28, 2020 Since the button had an ID, you should be able to use _IEGetObjById. Franz135 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Franz135 Posted July 28, 2020 Author Share Posted July 28, 2020 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 More sharing options...
Franz135 Posted July 28, 2020 Author Share Posted July 28, 2020 Quote Since the button had an ID, you should be able to use _IEGetObjById. Thanks, it worked! Link to comment Share on other sites More sharing options...
Franz135 Posted July 28, 2020 Author Share Posted July 28, 2020 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? Link to comment Share on other sites More sharing options...
Danp2 Posted July 28, 2020 Share Posted July 28, 2020 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 Franz135 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
water Posted July 28, 2020 Share Posted July 28, 2020 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 2024-07-28 - Version 1.6.3.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 (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 More sharing options...
Franz135 Posted July 28, 2020 Author Share Posted July 28, 2020 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 More sharing options...
Franz135 Posted July 28, 2020 Author Share Posted July 28, 2020 @water Because of corona it is only possible to go to the library if you get a ticket. Every day. So I have to fill out these tickets every day (twice) so that I can visit the library. I just want to save myself some work. Link to comment Share on other sites More sharing options...
Danp2 Posted July 28, 2020 Share Posted July 28, 2020 53 minutes ago, Franz135 said: But for all four of them I get the same (only the placeholder is different) 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? 🤔 Franz135 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Franz135 Posted July 28, 2020 Author Share Posted July 28, 2020 (edited) 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 July 28, 2020 by Franz135 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