CaptainBeardsEyesBeard Posted August 21, 2019 Share Posted August 21, 2019 Hi I'm trying to click a button and tried a few different ways This is the HTML for the button <button class="btn btn-info dim" style="float: right;" onclick="performSearch()">Search</button> So I tried this $oSubmitClick = _IEGetObjByName($oIE,"btn btn-info dim") _IEAction($oSubmitClick, "click") _IELoadWait($oIE,2000) But it doesn't work Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted August 21, 2019 Share Posted August 21, 2019 @CaptainBeardsEyesBeard That's because the property "name" doesn't exist in that element, as you can see. You should get it through the property "ClassName"; there are plenty samples on the Forum. P.S.: always add some error checking to your code, so you can see what is going on Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
mikell Posted August 21, 2019 Share Posted August 21, 2019 If several buttons have got the same classname, you might try _IETagNameGetCollection (button), then loop through the collection looking for innertext == "Search" Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted August 21, 2019 Author Share Posted August 21, 2019 9 minutes ago, mikell said: If several buttons have got the same classname, you might try _IETagNameGetCollection (button), then loop through the collection looking for innertext == "Search" Hmm So i tried this too 😕 Local $activeButtons= _IEGetObjById($oIE, "clientSearch") Sleep(5000) Local $oButtons = _IETagNameGetCollection($oIE, $activeButtons) For $oButton In $oButtons ;~ Check if Button InnerText equals Log In and perform an action. ;~ Uncomment the _IEAction line below to submit the form. If $oButton.InnerText = "Search" Then MsgBox(64, 'Search Found', 'Button found with value: ' & $oButton.InnerText, 4) _IEAction($oButton, 'click') Sleep(6000) _IEFormElementSetValue($oButton, "AutoIt IE.au3") MsgBox($MB_SYSTEMMODAL, "Test Result ", "Test passed: can't find search box " & $oButton.InnerText & "", 4) FileWrite($TestLog, @CRLF & "Test" & $TestCount & " Test passed: Can't find search box" & $ObjID.innerText) Else MsgBox($MB_SYSTEMMODAL, "Test Result ", "Test Failed: can't find search box " & $oButton.InnerText & "", 4) FileWrite($TestLog, @CRLF & "Test" & $TestCount & " Test failed: Can't find search box" & $ObjID.innerText) EndIf Next And the button I want is in this id <div class="tab-pane active" id="clientSearch"> <td colspan="2"> <div class="text-right"> <button class="btn btn-info dim" style="float: right;" onclick="performSearch()">Search</button> Link to comment Share on other sites More sharing options...
Nine Posted August 21, 2019 Share Posted August 21, 2019 If you put this after your tagnameGetCollection (buttons) : MsgBox (0,"Debug",IsObj ($oButtons)) What does it say to you ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted August 21, 2019 Author Share Posted August 21, 2019 I get a return of 1 Link to comment Share on other sites More sharing options...
Nine Posted August 21, 2019 Share Posted August 21, 2019 Hmmm, you are right. But it shouldn't cause your tagname is an object while it should be a string...Well I suppose it is kind of a feature. But if you test .lenght of the collection, you will see it is emply (0). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Danp2 Posted August 21, 2019 Share Posted August 21, 2019 4 hours ago, CaptainBeardsEyesBeard said: Local $oButtons = _IETagNameGetCollection($oIE, $activeButtons) Try changing this line to -- Local $oButtons = _IETagNameGetCollection($activeButtons, 'button') mikell 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted August 22, 2019 Author Share Posted August 22, 2019 I tried amending that line but no joy Link to comment Share on other sites More sharing options...
Danp2 Posted August 22, 2019 Share Posted August 22, 2019 If you want further assistance, you'll need to help us to help you. 😉 Post the results from the Scite output panel so that we can get a better idea of what's happening. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted August 29, 2019 Author Share Posted August 29, 2019 (edited) On 8/22/2019 at 1:13 PM, Danp2 said: If you want further assistance, you'll need to help us to help you. 😉 Post the results from the Scite output panel so that we can get a better idea of what's happening. By scite output you just mean this right? >"C:\Program Files\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\EliteAutomationKnowYourClient\Framework\TestEnv.au3" --> IE.au3 T3.0-2 Warning from function _IEAttach, $_IESTATUS_NoMatch >Exit code: 0 Time: 79.02 Any further assistance on this? To recap I'm using this code Local $oElements = _IETagNameGetCollection($oIE, "btn btn-info") For $oElement In $oElements if $oElement.classname=="AVI673" then _IEAction ($oElement, "click") EndIf ;ConsoleWrite ( $oElement.classname & @CRLF) next To try to access this html Edited August 29, 2019 by CaptainBeardsEyesBeard Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted August 29, 2019 Author Share Posted August 29, 2019 Also I tried this and couldn't click either 😕 local $oButtons = _IETagNameGetCollection($oIE, "btn btn-info") For $oButton In $oButtons ;~ Check if Button InnerText equals Log In and perform an action. ;~ Uncomment the _IEAction line below to submit the form. If $oButton.InnerText = "AVI673" Then MsgBox(64, 'AVI673 Found', 'Button found with value: ' & $oButton.InnerText, 4) _IEAction($oButton, 'click') Sleep(6000) _IEFormElementSetValue($oButton, "AutoIt IE.au3") MsgBox($MB_SYSTEMMODAL, "Test Result ", "Test passed: can't find button box " & $oButton.InnerText & "", 4) FileWrite($TestLog, @CRLF & "Test" & $TestCount & " Test passed: Can't find button box" & $ObjID.innerText) Else MsgBox($MB_SYSTEMMODAL, "Test Result ", "Test Failed: can't find button box " & $oButton.InnerText & "", 4) FileWrite($TestLog, @CRLF & "Test" & $TestCount & " Test failed: Can't find button box" & $ObjID.innerText) EndIf Next Link to comment Share on other sites More sharing options...
Subz Posted August 29, 2019 Share Posted August 29, 2019 "btn btn-info" is not a tag name, tags are "div", "tr" or "button", here is a basic working example of clicking a button tag. #include <IE.au3> Local $oIE = _IECreate("https://sweetalert2.github.io/", 1) Local $oButtons = _IETagNameGetCollection($oIE, "button") If @error Then MsgBox(4096, "", "Error - Unable getting button collection" & @CRLF & "Error : " & @error) If IsObj($oButtons) Then For $oButton In $oButtons If StringInStr($oButton.innerText, "Show normal alert") Then MsgBox(4096, "", "Clicking Show normal message") _IEAction($oButton, "Click") EndIf If StringInStr($oButton.innerText, "Show success message") Then MsgBox(4096, "", "Clicking Show success message button") _IEAction($oButton, "Click") EndIf Next EndIf Link to comment Share on other sites More sharing options...
CaptainBeardsEyesBeard Posted August 29, 2019 Author Share Posted August 29, 2019 So this would be correct? local $oButtons = _IETagNameGetCollection($oIE, "button") For $oButton In $oButtons ;~ Check if Button InnerText equals Log In and perform an action. ;~ Uncomment the _IEAction line below to submit the form. If $oButton.InnerText = "AVI673" Then MsgBox(64, 'AVI673 Found', 'Button found with value: ' & $oButton.InnerText, 4) _IEAction($oButton, 'click') Sleep(6000) _IEFormElementSetValue($oButton, "AutoIt IE.au3") MsgBox($MB_SYSTEMMODAL, "Test Result ", "Test passed: can't find button box " & $oButton.InnerText & "", 4) FileWrite($TestLog, @CRLF & "Test" & $TestCount & " Test passed: Can't find button box" & $ObjID.innerText) Else MsgBox($MB_SYSTEMMODAL, "Test Result ", "Test Failed: can't find button box " & $oButton.InnerText & "", 4) FileWrite($TestLog, @CRLF & "Test" & $TestCount & " Test failed: Can't find button box" & $ObjID.innerText) EndIf Next 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