mLipok Posted April 15, 2021 Share Posted April 15, 2021 (edited) 36 minutes ago, Danp2 said: Ideally, the solution would be a generic "builder" for the Desired Capabilities that wouldn't require a separate function for each "action". Do you mean something like this: Func _Example2() Local $a_WD_CAP _WD_Capabilities_Add($a_WD_CAP, $_WD_CAP_GECKO_OPTION_BINARY, 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe') _WD_Capabilities_Add($a_WD_CAP, $_WD_CAP_GECKO_OPTION_LOGLEVEL, 'trace') _WD_Capabilities_Add($a_WD_CAP, $_WD_CAP_GECKO_OPTION_ARGS, '-profile', 'C:\Users\agatk\AppData\Roaming\Mozilla\Firefox\Profiles\5819ktj7.default') Local $sDesiredCapabilities = _WD_Capabilities_Create($a_WD_CAP) Return $sDesiredCapabilities EndFunc ;==>_Example2 ? or even better this way: _Example3() Func _Example3() ; ....... Local $s_Desired_Capabilities = _My_Chrome_Capabilities() ; ....... EndFunc ;==>_Example3 Func _My_Chrome_Capabilities() _WD_Capabilities_Reset() _WD_Capabilities_Add($_WD_CAP_GECKO_OPTION_BINARY, 'C:\Program Files (x86)\Mozilla Firefox\firefox.exe') _WD_Capabilities_Add($_WD_CAP_GECKO_OPTION_LOGLEVEL, 'trace') _WD_Capabilities_Add($_WD_CAP_GECKO_OPTION_ARGS, '-profile', 'C:\Users\agatk\AppData\Roaming\Mozilla\Firefox\Profiles\5819ktj7.default') Local $sDesiredCapabilities = _WD_Capabilities_Create() Return SetError(@error, @extended, $sDesiredCapabilities) EndFunc ;==>_My_Chrome_Capabilities Edited April 15, 2021 by mLipok 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 Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Marlon13 Posted April 15, 2021 Share Posted April 15, 2021 (edited) hello sorry again I'm trying to retrieve some data inside a table in the scite log I see that there are but the array does not return me, maybe I am wrong something? expandcollapse popup#include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <File.au3> #include <Array.au3> #include "wd_core.au3" #include "wd_helper.au3" #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> Global $sDesiredCapabilities, $sSession, $sElement Global $sGPathProfileBrowser = "C:/Users/Marlon/AppData/Roaming/Mozilla/Firefox/Profiles/fechpd3a.default-release" SetupGecko(1) _WD_Startup() If @error <> $_WD_ERROR_Success Then Exit -1 EndIf $sSession = _WD_CreateSession($sDesiredCapabilities) _ScrapeEconCalendar() MsgBox(0, "", "") _WD_DeleteSession($sSession) _WD_Shutdown() Func _ScrapeEconCalendar() _WD_Navigate($sSession, "https://www.myfxbook.com/forex-economic-calendar") Local $aResult = _WD_GetTable($sSession, "//table[@id='economicCalendarTable']") _ArrayDisplay($aResult) EndFunc ;==>_ScrapeEconCalendar Func SetupGecko($iNewOldBrowser) If $iNewOldBrowser = 0 Then _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace --marionette-port 2828') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}' Else _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace --marionette-port 2828') _WD_Option('Port', 4444) $sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["-profile", "' & $sGPathProfileBrowser & '"],"log": {"level": "trace"}}}}}' EndIf EndFunc ;==>SetupGecko sorry _WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"EUR"}... _WD_ElementAction: {"value":"EUR"}... __WD_Get: URL=HTTP://127.0.0.1:4444/session/b88a9748-a67a-42a7-aa7d-686c8b220bb3/element/a3cf1b11-08ba-4ba7-a428-f6e3aed40cb2/text __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"Consumer Price Index (EU norm) (MoM)"}... _WD_ElementAction: {"value":"Consumer Price Index (EU norm) (MoM)"}... __WD_Get: URL=HTTP://127.0.0.1:4444/session/b88a9748-a67a-42a7-aa7d-686c8b220bb3/element/ef304502-5721-484b-8dcc-2e16bb42c500/text __WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"LOW"}... _WD_ElementAction: {"value":"LOW"}... "C:\Users\Marlon\Desktop\economic calendart\wd_helper.au3" (1846) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $aTable[$iRow][$iColumn] = _WD_ElementAction($sSession, $aElements[$i], "Text") ^ ERROR I only entered the final part because everything would have been very long, thanks again Edited April 15, 2021 by Marlon13 Link to comment Share on other sites More sharing options...
Danp2 Posted April 15, 2021 Author Share Posted April 15, 2021 42 minutes ago, mLipok said: _WD_Capabilities_Add Exactly. Something that can be used to build the Desired Capabilities for any supported browser. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
mLipok Posted April 15, 2021 Share Posted April 15, 2021 (edited) 17 minutes ago, Danp2 said: Something that can be used to build the Desired Capabilities for any supported browser. _WD_Capabilities_Add() will be able to do so, provided we take all cases into account. It certainly won't happen right away, but we can start with the simplest and supplement it over time. Edited April 15, 2021 by mLipok Danp2 1 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 Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 * My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related: * How to use IE.au3 UDF with AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
Danp2 Posted April 15, 2021 Author Share Posted April 15, 2021 @Marlon13 A couple of suggestions when requesting help -- Post code that we can actually run without modification. Include the Scite output so that we can examine it for results, errors, etc. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted April 15, 2021 Share Posted April 15, 2021 @Marlon13 Put some error handling in your code for now on. You would have noticed that way you are missing one very important include for reading tables. “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 April 15, 2021 Author Share Posted April 15, 2021 @Nine If you're referring to the HtmlTable2Array UDF, then that is an optional UDF and _WD_GetTable should work without it. 🙂 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Nine Posted April 15, 2021 Share Posted April 15, 2021 It does not for me (Win7). If I comment out the include I get multiple errors and there is no array. But if I include it, it works like a charm... “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...
Sopr Posted April 16, 2021 Share Posted April 16, 2021 Is there any debuggers that work with the WD Driver? I tried using the Graphical Debugger from here http://www.thefoolonthehill.net/drupal/AutoIt Debugger, but when I try to run it step by step, it just jumps between WinHttps and wd_core in a perpetual loop, after 20 minutes of this I stopped it. Is there any good tutorials or videos on how to click on buttons, links and banners on the webpage for beginners? Wiki is not too descriptive and does not have syntax or examples. Link to comment Share on other sites More sharing options...
Marlon13 Posted April 16, 2021 Share Posted April 16, 2021 hello sorry I have a problem with the browser now in practice after closing the script and disabled marionette every time I try to open the browser is not open and a completely white message box appears with the title firefox and an ok button I press it and it does not start firefox, has this ever happened to you? bye thank you Link to comment Share on other sites More sharing options...
Chuckero Posted April 16, 2021 Share Posted April 16, 2021 I'm using the function _WD_UpdateDriver() to automatically update the chromedriver, it's working very well, but there is one issue: when there is no file the function returns the error $_WD_ERROR_NoMatch. It would be very nice if this function could download the file anyway. For instance, in a new installation of the script, this update could be very helpful. I can do it and send a pull request if you wish. Link to comment Share on other sites More sharing options...
Danp2 Posted April 16, 2021 Author Share Posted April 16, 2021 @Chuckero It should already work that way if you call it with $lForce parameter equal True. Chuckero 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Blueman Posted April 18, 2021 Share Posted April 18, 2021 (edited) Hi @Danp2, I was wondering if this UDF also supports "Shadow DOM's". Because i am trying to interact with an element (in this case a Button), but it won't work, also with other elements inside the DOM it doesn't work. Elements outside of the DOM works just fine, so i thought that maybe DOM's are not supported with this UDF? Using this code; ;Find Element $aElements = _WD_FindElement($WLF_Session, $_WD_LOCATOR_ByXPath, ".//button[contains(text(),'Filter')]", Default, False, Default) ;Show Element ID when found Msgbox(48,"",$aElements) ;Click on the Button _WD_ElementAction($WLF_Session,$aElements,'click') In the developer console in Chrome, when i inspect the element, i notice the structure; <html> <body> <statup-app> #shadow-root (open) <style>...</style> <div> <button> "Filter " <span id="arrow" class="down"></span> </button> </div> etc,etc,etc Everything after #shadow-root (open) i cannot interact with, but anything before i can interact with. Thanks Edited April 18, 2021 by Blueman Added code Link to comment Share on other sites More sharing options...
Danp2 Posted April 18, 2021 Author Share Posted April 18, 2021 @Blueman Shadowroot support was only recently added to the W3C specs, so shadow root support is limited / spotty depending on the browser involved. There is _WD_GetShadowRoot, which should work to obtain the shadow root and access its contents. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
JMan14 Posted April 20, 2021 Share Posted April 20, 2021 I have this code in Python, generated by Selenium IDE def test_enm(self): self.driver.get("https://teco3enmui.nh.inet/login/?goto=https://teco3enmui.nh.inet") self.driver.set_window_size(864, 708) self.driver.find_element(By.ID, "loginNoticeOk").click() self.driver.find_element(By.ID, "loginUsername").send_keys("opjcman1") self.driver.find_element(By.ID, "loginPassword").send_keys("xxxxx") self.driver.find_element(By.ID, "submit").click() self.driver.find_element(By.LINK_TEXT, "Alarm Monitor (FM)").click() self.vars["window_handles"] = self.driver.window_handles self.driver.find_element(By.CSS_SELECTOR, ".ebBtn:nth-child(1) > .elLayouts-ActionBarButton-text").click() # How can I write this 4 lines with Autoit and WebDriver UDF? self.vars["win7895"] = self.wait_for_window(2000) self.vars["root"] = self.driver.current_window_handle self.driver.switch_to.window(self.vars["win7895"]) self.driver.switch_to.window(self.vars["root"]) self.driver.find_element(By.LINK_TEXT, "opjcman1").click() self.driver.find_element(By.CSS_SELECTOR, ".eaUserProfileMenu-link-logout").click() #And this other 4 lines? self.driver.switch_to.window(self.vars["win7895"]) self.driver.close() self.driver.switch_to.window(self.vars["root"]) self.driver.close() Thanks in advance... Link to comment Share on other sites More sharing options...
TheOne23 Posted April 20, 2021 Share Posted April 20, 2021 Hi Danp2, Do you have something or function that can start a session or new tab and use "Browse as guest"? Thank you in advance. Regards, TheOne23 Link to comment Share on other sites More sharing options...
Danp2 Posted April 20, 2021 Author Share Posted April 20, 2021 @TheOne23 No, and it's not clear to me why you would need this. Can you elaborate? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danp2 Posted April 20, 2021 Author Share Posted April 20, 2021 @JMan14 I'm don't have much experience with Python or Selenium, so someone else may jump in here with some better info. To me, it appears that the code gathers some window or tab handles and stores them in local variables. These are then used to switch to that window context. You would use _WD_Window to retrieve / set the current window. If your last set of code is closing the window / tabs, then you would use _WD_Window for this as well. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TheOne23 Posted April 20, 2021 Share Posted April 20, 2021 Hi Danp2, I need this since it is restricting the automation to push through while authenticating. But if I pause the automation and selected the "browse as guess" then it is working fine. Link to comment Share on other sites More sharing options...
Danp2 Posted April 20, 2021 Author Share Posted April 20, 2021 @TheOne23 Looks like Chrome / MSEdge accept a command line switch to enable guest mode. You should be able to incorporate this into your DesiredCapabilities string. For examples, search the forum for the term "args". Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts