Chuckero Posted March 22, 2021 Share Posted March 22, 2021 45 minutes ago, Nine said: Not sure how long it is going to work. You may need to adapt it to new (or old) version. WOW! If it works for while, is good enough. Thanks! Link to comment Share on other sites More sharing options...
Danp2 Posted March 22, 2021 Author Share Posted March 22, 2021 @Chuckero Why not use _WD_UpdateDriver to automatically download the correct driver version? Hint: Search wd_helper.au3 for "$sDriverVersion" to see how to grab the driver version by launching the driver. Chuckero 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
careca Posted March 24, 2021 Share Posted March 24, 2021 Hi, im trying to interact with binance.com, i would like to press a button and retrieve a table, but it seems cant do any of that, looked into the demos, but couldn't figure it out. What im trying to do: get into https://www.binance.com/en/markets, press BTC Markets, and get all the values from the table. What i tried so far: expandcollapse popup#include "wd_core.au3" #include "wd_helper.au3" #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> Local $sDesiredCapabilities, $iIndex, $sSession SetupGecko() _WD_Startup() $sSession = _WD_CreateSession($sDesiredCapabilities) _WD_Navigate($sSession, "https://www.binance.com/en/markets") _WD_LoadWait($sSession, Default, Default, Default) ; Locate a single element $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@class='css-1vs0no5']") ;Button Class, doesn't use name. ; Get element's coordinates $oERect = _WD_ElementAction($sSession, $sElement, 'rect') ConsoleWrite("Element Coords = " & $oERect.Item('x') & " / " & $oERect.Item('y') & " / " & $oERect.Item('width') & " / " & $oERect.Item('height') & @CRLF) ; Click search button $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='BTC Markets']") _WD_ElementAction($sSession, $sButton, 'click') _WD_LoadWait($sSession, 2000) $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@class='css-1vs0no5']") $sValue = _WD_ElementAction($sSession, $sElement, 'property', 'value') ConsoleWrite('value = ' & $sValue & @CRLF) MsgBox($MB_ICONINFORMATION, "Demo complete!", "Click ok to shutdown the browser and console") _WD_DeleteSession($sSession) _WD_Shutdown() Func SetupGecko() _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace') _WD_Option('DriverParams', '--binary "C:\Program Files\Mozilla Firefox\firefox.exe"') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}' EndFunc On a side note, i considered getting the source but somehow, the values from the table do not show up in it, i don't understand much about browsers but i guess the table loads in a different manner. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
AshishSaklani Posted March 24, 2021 Share Posted March 24, 2021 (edited) hi @Danp2 i am stuck on some jQuery accordion giving me trouble selecting option which is not a select nor button all controlled by java script any way you can suggest add a class name on a element <table id="T301394438" title="" class="BaseTable"><colgroup cols="8"><col style="width: 80px;"><col style="width: 80px;"><col style="width: 100px;"><col style="width: 104px;"><col style="width: 99px;"><col style="width: 81px;"><col style="width: 59px;"><col style="width: 100px;"></colgroup> <tbody> here content appear in tables with ajax <tr class="CLICKED"> one we click class name is added with some java script <tr class="" > <tr class=""> <tr class=""> </tbody> </table> i was not able to find Javascript controlling that click i tried _WD_Attach($sSession,'Third Level Search') $element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,"//*[@id='T301394438']/tbody/tr[2]") _WD_ExecuteScript($sSession,"( document.getElementsByTagName('tr')[8].classList.add('Clicked');") ;or another attempt _WD_Attach($sSession,'Third Level Search') $element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,"//*[@id='T301394438']/tbody/tr[2]") _WD_ElementAction($sSession,$element,'click') _WD_ElementAction($sSession,$element,'doubleclick') page where i am running is third paage open with WD_attach and if i run javascript on browser console i see'clicked' class added somehow selection is managed with hover focus and click i am not sure; I am new with blog questions pls forgive me if it sounds silly or details are not complete I have also tried with iframe there is only 1 empty iframe at different place nothing works help me please Edited March 24, 2021 by AshishSaklani Link to comment Share on other sites More sharing options...
Danp2 Posted March 24, 2021 Author Share Posted March 24, 2021 @AshishSaklani You will need to provide additional details before I can offer any suggestions on how to accomplish your task. Some general comments -- You mentioned "jQuery Accordion". I took a look at one of these and the HTML looked very different than what you posted. Is the website publicly accessible? If yes, please provide the URL. If no, then try to find another website that can be used to demonstrate the problem It's often helpful to see the resulting output from Scite. If you need to perform a double click on an element, then you need to use _WD_ElementActionEx (your code likely generated an error because _WD_ElementAction doesn't support a doubleclick option) Please show us the javascript you ran in the browser console. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted March 24, 2021 Author Share Posted March 24, 2021 12 hours ago, careca said: binance.com If you check the forum, there have been past discussions on this site. Suggest that you look into their API, which should be easier and more accurate than trying to scrape the data from the website. careca 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Chuckero Posted March 24, 2021 Share Posted March 24, 2021 (edited) 12 hours ago, careca said: Hi, im trying to interact with binance.com, i would like to press a button and retrieve a table, but it seems cant do any of that, looked into the demos, but couldn't figure it out. What im trying to do: get into https://www.binance.com/en/markets, press BTC Markets, and get all the values from the table. What i tried so far: Hey @careca, why don't you try to use the Binance API? It is pretty mature and full of features, this way you can get the quotes directly from the source. If so, maybe AutoIt is not the best tool for this. Take a look at this post about web requests: Binance get markets: https://api.binance.com/api/v3/exchangeInfo Get all the tickers: https://www.binance.com/api/v3/ticker/bookTicker The full API: https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md Good lucky Edited March 24, 2021 by Chuckero Added some extra info. careca 1 Link to comment Share on other sites More sharing options...
HJL Posted March 25, 2021 Share Posted March 25, 2021 (edited) Hi Dan, I have problems with clicking the submit ("Anmelden") button on this page: https://vertriebspartner.dela.de/partner-login $sSubmitXPath = "/html/body/main/div[1]/div/div/div/div/div/form/input[2]" _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sSubmitXPath) _WD_ElementAction($sSession, $sElement, 'click') $sSubmitXPath = "//*[@id="c1948"]/div/form/input[3]" ; also doesn't work even when 1948 is correct (changes sometime to 1949 or other). On some clients it works, on others not (with chrome). Is there a function to highlight or mark in another way what _WD_FindElement() has found? Edited March 25, 2021 by HJL Link to comment Share on other sites More sharing options...
seadoggie01 Posted March 25, 2021 Share Posted March 25, 2021 In wd_helper.au3, _WD_HighlightElement All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
Danp2 Posted March 25, 2021 Author Share Posted March 25, 2021 @HJL FWIW, ChroPath gives a relative xpath of "//input[@type='submit']", which should be more reliable than your earlier attempts. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
HJL Posted March 28, 2021 Share Posted March 28, 2021 Thanks to both of you: _WD_HighlightElement works fine (I can use it for future problems) and "//input[@type='submit']" is perfect because it helps against the changing number in the XPath. But the problem actually was the chrome-profile on one client. After deleting it everything was ok - I didn't find the reason, just a workaround. Next problem, and I already tried ChroPath - how to get around with the numbers in the following XPath? Is it possible to do something like "input[id=*'btn_login'] or "input[id='main_'&*&'btn_login'] ? Link to comment Share on other sites More sharing options...
Danp2 Posted March 28, 2021 Author Share Posted March 28, 2021 @HJL You should be able to match on a partial name or id using the xpath contains() function. You will find multiple examples if you search this thread. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
moxasya Posted March 29, 2021 Share Posted March 29, 2021 hi dan, i have some question regarding multi run .exe at the same time / simultaneously i have multi exe with only difference login id n password.. so i want run all at same time. for now i only try 2 run at same time to see if the code work. is there any code to exchange here? Func SetupChrome() _WD_Option('Driver', 'C:\Setup\Tools\AutoIt\Common\chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' EndFunc my error is when run 2.. only last one .exe work.. first one .exe error like this thank in advance !! Link to comment Share on other sites More sharing options...
Danp2 Posted March 29, 2021 Author Share Posted March 29, 2021 @moxasya I believe that you have a couple of options -- Run a single instance of Chromedriver, which should be able to support multiple sessions Run separate instances of Chromedriver where each one uses a unique port number. I know this has been discussed previously on the forum, but can't recall if it was in this thread or the development one. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
moxasya Posted March 29, 2021 Share Posted March 29, 2021 53 minutes ago, Danp2 said: @moxasya I believe that you have a couple of options -- Run a single instance of Chromedriver, which should be able to support multiple sessions Run separate instances of Chromedriver where each one uses a unique port number. I know this has been discussed previously on the forum, but can't recall if it was in this thread or the development one. i try the first one. i found other discussion in here and u say put at beginning Func SetupChrome() _WD_Option('DriverClose', False) ;addon to solve multiple session issue _WD_Option('Driver', 'C:\Setup\Tools\AutoIt\Common\chromedriver.exe') _WD_Option('Port', 9515) _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"') $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}' EndFunc however return error Link to comment Share on other sites More sharing options...
Danp2 Posted March 29, 2021 Author Share Posted March 29, 2021 @moxasya It sounds like you are using a very old version of the UDF as that feature was added in v.0.2.0.8 almost a year ago. You will need to update to use that option. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
JMan14 Posted April 3, 2021 Share Posted April 3, 2021 I made a code in VBA Excel with Selenium. And I need to pass it to Autoit. But I couldn't emulate the following instructions: SwitchToFrame and SwitchToDefaultContent example: ch.SwitchToFrame (0) and this other instruction: ch.SwitchToDefaultContent ch is: Set ch = New Selenium.ChromeDriver Does anyone know how to do it in Autoit? Thanks in advance. Link to comment Share on other sites More sharing options...
Danp2 Posted April 3, 2021 Author Share Posted April 3, 2021 @JMan14 In the future, please use ctrl-shift-v to paste normal or use the copy feature of google translator (instead of highlighting it). That way the text will appear "normal" size in your post. 🙂 If you want to switch frames using the Webdriver UDF, then you would do something like this -- ; Switch to frame by index _WD_FrameEnter($sSession, "0") ; Perform frame activity here ; Return to top level _WD_FrameEnter($sSession, Null) ; You could also use _WD_FrameLeave here Hope this helps. If I've misunderstood your goal, then please clarify for us. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
HJL Posted April 3, 2021 Share Posted April 3, 2021 Hi Dan, is it possible to retrieve the XPath of a field or button when clicking it with the mouse? I often have to find XPathes and up to now I use "inspect" and "copy" in chrome. It would be much easier to have a script that retrieves the XPath of the clicked item in memory or into a variable like copy and paste. Link to comment Share on other sites More sharing options...
Danp2 Posted April 3, 2021 Author Share Posted April 3, 2021 @HJL Not sure about that. FWIW, I use Chropath extensively for this. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts