kornholeking Posted April 11, 2022 Share Posted April 11, 2022 Hello, I am new to AutoIT and have been doing a little bit a research in the help guides, FAQs, and forums to try and figure out the most basic and least complicated way to click on a link in Chrome using AutoIT. From what I have gathered, it seems that this is not really out of the box capability and there are a few extensions and/or UDFs that are required to even begin working with Chrome (please feel free to comment/correct if this is not true.) I have tried to follow the instructions for WebDriver but am receiving an error when performing the "demo test". I'm not sure how else to check or test it, but any insight or guidance would be greatly appreciated as I am just starting out and trying to learn the basics of this scripting language. Link to comment Share on other sites More sharing options...
Danp2 Posted April 12, 2022 Share Posted April 12, 2022 Hi @kornholeking, A good first step would be to provide additional details on the error that you are receiving. Without that, we can only guess at the issue. Dan Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kornholeking Posted April 19, 2022 Author Share Posted April 19, 2022 Hi @Danp2, Sorry for my late response. I've pasted the console log below from when I try to run the wd_demo. Let me know if you need me to provide anything else, and thank you in advance for any assistance provided! _WD_UpdateDriver ==> Success (0 / 0) : DriverCurrent = 100.0.4896.60 : DriverLatest = 100.0.4896.60 _WD_CapabilitiesAdd: TESTING #183 $key = alwaysMatch $value1 = chrome $value2 = :: DEBUG _WD_CapabilitiesAdd: TESTING #243/250 $key = w3c $value1 = True $value2 = $s_Notation = [capabilities][alwaysMatch]["goog:chromeOptions"][w3c] <<<< True :: DEBUG _WD_CapabilitiesAdd: TESTING #220/250 $key = excludeSwitches $value1 = enable-automation $value2 = $s_Notation = [capabilities][alwaysMatch]["goog:chromeOptions"][excludeSwitches][0] <<<< enable-automation :: DEBUG _WD_CapabilitiesDump: _WD_Capabilities: API START: 785 _WD_CapabilitiesDump: - $_WD_CAPS__API: Rows= 1 _WD_CapabilitiesDump: - $_WD_CAPS__API: Cols= 5 $_WD_CAPS__API : alwaysMatch|||goog:chromeOptions| _WD_CapabilitiesDump: _WD_Capabilities: API END: 785 _WD_CapabilitiesDump: _WD_Capabilities: JSON START: 785 _WD_CapabilitiesDump: { "capabilities":{ "alwaysMatch":{ "goog:chromeOptions":{ "w3c":true, "excludeSwitches":[ "enable-automation" ] } } } } _WD_CapabilitiesDump: _WD_Capabilities: JSON END: 785 _WD_IsLatestRelease ==> Success (0) : True _WD_Startup: OS: WIN_10 WIN32_NT 18363 _WD_Startup: AutoIt: 3.3.16.0 _WD_Startup: Webdriver UDF: 0.8.1 (Up to date) _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) _WD_Startup: Driver: chromedriver.exe (32 Bit) _WD_Startup: Params: --verbose --log-path="C:\Program Files (x86)\AutoIt3\Include\chrome.log" _WD_Startup: Port: 9515 _WD_Startup: Command: "chromedriver.exe" --verbose --log-path="C:\Program Files (x86)\AutoIt3\Include\chrome.log" _WD_Startup ==> General Error (1) : Error launching WebDriver! _WD_GetSession ==> Success (0) Link to comment Share on other sites More sharing options...
Nine Posted April 19, 2022 Share Posted April 19, 2022 Try first download latest WinHTTP version of the UDF as mentioned in the console... Danp2 1 “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...
kornholeking Posted April 19, 2022 Author Share Posted April 19, 2022 Hi @Nine, I believe I have already done this and moved the files in the same directory (C:\Program Files (x86)\AutoIt3\Include) as the rest of the script files. Am I missing another step? Link to comment Share on other sites More sharing options...
Danp2 Posted April 20, 2022 Share Posted April 20, 2022 @kornholekingSee here for the proper way to add UDFs to your system. It's possible that you have more than one copy of WinHttp.au3 saved on your system. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kornholeking Posted April 20, 2022 Author Share Posted April 20, 2022 Hi @Danp2, The demo test worked after setting up my own personal "include" folder - thank you. Now, I have gone as far as being able to create something very simple by using the ChromeStartup function to launch a Chrome window and navigate to, let's say Google at this point. What is the next function I would need to be able to click a link by text (not button nor within the search text field)? Link to comment Share on other sites More sharing options...
Danp2 Posted April 20, 2022 Share Posted April 20, 2022 See _WD_LinkClickByText, which is essentially a wrapper for _WD_FindElement and _WD_ElementAction. Be sure the check out the included help file if you haven't already done so. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kornholeking Posted April 21, 2022 Author Share Posted April 21, 2022 I see _WD_LinkClickByText.. I guess I'm not sure how to properly create the function itself. The help file has a list of the WD functions, but no other information for some reason. Using WD, here's my guess as to how I would launch a browser window, navigate to google, and click on a link: _WD_Startup _WD_Navigate _WD_LoadWait _WD_LinkClickByText Assuming those are the correct steps, what exactly is the syntax for each function?? Link to comment Share on other sites More sharing options...
Danp2 Posted April 21, 2022 Share Posted April 21, 2022 You need to determine why the help file isn't properly displaying. Possible causes -- located on network share need to click the Unblock button in Properties Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kornholeking Posted April 21, 2022 Author Share Posted April 21, 2022 (edited) Unblocked the file in Properties worked, thanks! Back to my assumption: _WD_CreateSession _WD_Navigate($sSession, "www.google.com") _WD_LoadWait($sSession) _WD_LinkClickByText($sSession, "About") Does that seem correct thus far? Should I assign $sSession initially or how/when does this get assigned? Edited April 21, 2022 by kornholeking Link to comment Share on other sites More sharing options...
kornholeking Posted April 28, 2022 Author Share Posted April 28, 2022 For some reason I'm unable to launch WebDriver now when trying to simply run _WD_Startup. Below is what I'm getting in from the console: >Running:(3.3.16.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\AutoIT\test.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. _WD_IsLatestRelease ==> Success (0) : True _WD_Startup: OS: WIN_10 WIN32_NT 18363 _WD_Startup: AutoIt: 3.3.16.0 _WD_Startup: Webdriver UDF: 0.8.1 (Up to date) _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) _WD_Startup: Driver: C:\temp\AutoIT (32 Bit) _WD_Startup: Params: _WD_Startup: Port: 0 _WD_Startup: Command: "C:\temp\AutoIT" _WD_Startup ==> General Error (1) : Error launching WebDriver! +>14:56:47 AutoIt3.exe ended.rc:0 +>14:56:47 AutoIt3Wrapper Finished. >Exit code: 0 Time: 4.513 Not sure what has changed as I was able to at least launch Chrome and navigate to Google last week.. Any ideas? Link to comment Share on other sites More sharing options...
Danp2 Posted April 29, 2022 Share Posted April 29, 2022 4 hours ago, kornholeking said: _WD_Startup: WinHTTP: 1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>) Please follow that link and update your WinHTTP source. Quote Not sure what has changed. Any ideas? It seems that you haven't properly set some parameters with _WD_Option. You'll need something like this -- _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) Quote _WD_Startup: Driver: C:\temp\AutoIT (32 Bit) Any idea where "C:\temp\AutoIT" is coming from? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kornholeking Posted May 4, 2022 Author Share Posted May 4, 2022 I've attempted to "update" my WinHTTP source several times using that link. It is the latest available as far as I can tell. I'm sorry, but would I set the _WD_Option parameter individually within my script or is there somewhere that else that it is set globally? "C:\temp\AutoIT" is where my personal UDFs are located and where I am attempting to run my "test script" from as well. Link to comment Share on other sites More sharing options...
Danp2 Posted May 4, 2022 Share Posted May 4, 2022 @kornholeking Go to that link, copy the full text, and then paste it into the existing winhttp.au3 replacing the older code. Also, make sure that you don't have another copy of winhttp.au3 laying around that is interfering. Each script is responsible for configuring the UDF "environment" before attempting to launch the webdriver. There isn't any global location to do this. You must have done something like the following to get that -- WD_Option('Driver', 'C:\temp\AutoIT\') This isn't valid and would cause _WD_Startup to fail because you haven't properly defined the location of the webdriver. Maybe you meant something like this? WD_Option('Driver', 'C:\temp\AutoIT\chromedriver.exe') Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kornholeking Posted May 5, 2022 Author Share Posted May 5, 2022 @Danp2 I went to the link and overwritten my WinHttp.au3; also was able to find and update WD_Option to point to the chromedriver executable as you mentioned. It looks like I'm now able to start a session but creating a session doesn't seem to be working properly, I think? My script at this point is simply: _WD_Startup _WD_CreateSession Console: >Running:(3.3.16.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\AutoIT\test.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. _WD_IsLatestRelease ==> Success (0) : False _WD_Startup: OS: WIN_10 WIN32_NT 18363 _WD_Startup: AutoIt: 3.3.16.0 _WD_Startup: Webdriver UDF: 0.8.1 (Update available) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: C:\temp\AutoIT\chromedriver.exe (32 Bit) _WD_Startup: Params: _WD_Startup: Port: 0 _WD_Startup: Command: "C:\temp\AutoIT\chromedriver.exe" __WD_Post: URL=HTTP://127.0.0.1:0/session; $sData={} __WD_Post ==> Success (0) HTTP status = 404 : ResponseText=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <HTML><HE... _WD_CreateSession: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>Not Found</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD> <BODY><h2>Not Found</h2> <hr><p>HTTP Error 404. The requested resource is not found.</p> </BODY></HTML> _WD_CreateSession ==> Webdriver Exception (10) HTTP status = 404 +>13:11:32 AutoIt3.exe ended.rc:0 +>13:11:32 AutoIt3Wrapper Finished. >Exit code: 0 Time: 7.14 Link to comment Share on other sites More sharing options...
Danp2 Posted May 5, 2022 Share Posted May 5, 2022 11 minutes ago, kornholeking said: also was able to find and update WD_Option to point to the chromedriver executable as you mentioned It's not clear what you did here, but you shouldn't be modifying the UDF code (if that's what you did). Do this instead -- _WD_Option('Driver', 'C:\temp\AutoIT\chromedriver.exe') Quote _WD_Startup: Port: 0 You haven't defined the port the UDF should use to communicate with the webdriver. I posted it for you earlier, but I'll share it again -- _WD_Option('Port', 9515) P.S. If you review the output from _WD_Startup, you'll see that there's an updated version of the UDF available for download Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kornholeking Posted May 5, 2022 Author Share Posted May 5, 2022 I completely wiped and updated my WD UDFs, because I think I might have inadvertently updated the UDF code previously at some point - Thank you. Starting from scratch, again. You mention _WD_Option, so I'm guessing that is needing to be included in my script as well? Not really sure, but I tried the following out: _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Startup_WD_CreateSession Console: >Running:(3.3.16.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\AutoIT\test.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. _WD_IsLatestRelease ==> Success (0) : True _WD_Startup: OS: WIN_10 WIN32_NT 18363 _WD_Startup: AutoIt: 3.3.16.0 _WD_Startup: Webdriver UDF: 0.9.0 (Up to date) _WD_Startup: WinHTTP: 1.6.4.2 _WD_Startup: Driver: chromedriver.exe (32 Bit) _WD_Startup: Params: _WD_Startup: Port: 9515 _WD_Startup: Command: "chromedriver.exe" __WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={} __WD_Post ==> Invalid argument (5) HTTP status = 400 : ResponseText={"value":{"error":"invalid argument","message":"invalid argument: 'capabilities' must be a JSON obje... _WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: 'capabilities' must be a JSON object","stacktrace":"Backtrace:\n\tOrdinal0 [0x009B7413+2389011]\n\tOrdinal0 [0x00949F61+1941345]\n\tOrdinal0 [0x0083C658+837208]\n\tOrdinal0 [0x0088807E+1147006]\n\tOrdinal0 [0x0088776C+1144684]\n\tOrdinal0 [0x00888A95+1149589]\n\tOrdinal0 [0x008888DA+1149146]\n\tOrdinal0 [0x00883F66+1130342]\n\tOrdinal0 [0x0085E546+976198]\n\tOrdinal0 [0x0085F456+980054]\n\tGetHandleVerifier [0x00B69632+1727522]\n\tGetHandleVerifier [0x00C1BA4D+2457661]\n\tGetHandleVerifier [0x00A4EB81+569713]\n\tGetHandleVerifier [0x00A4DD76+566118]\n\tOrdinal0 [0x00950B2B+1968939]\n\tOrdinal0 [0x00955988+1989000]\n\tOrdinal0 [0x00955A75+1989237]\n\tOrdinal0 [0x0095ECB1+2026673]\n\tBaseThreadInitThunk [0x76706359+25]\n\tRtlGetAppContainerNamedObjectPath [0x776287D4+228]\n\tRtlGetAppContainerNamedObjectPath [0x776287A4+180]\n"}} _WD_CreateSession ==> Webdriver Exception (10) HTTP status = 400 +>16:21:29 AutoIt3.exe ended.rc:0 +>16:21:29 AutoIt3Wrapper Finished. >Exit code: 0 Time: 7.648 Link to comment Share on other sites More sharing options...
Danp2 Posted May 5, 2022 Share Posted May 5, 2022 _WD_CreateSession needs a Capabilities string. An empty JSON string is used when you don't supply one. You can build this string manually (search the forum for $sCapabilities or $sDesiredCapabilities to locate some examples) or you can use the functions in wd_capabilities.au3 (see this page on the wiki for details) Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
kornholeking Posted May 6, 2022 Author Share Posted May 6, 2022 @Danp2 Is there a difference between using $sCapabilities and $sDesiredCapabilities? After browsing through some posts on the forum and reviewing the FAQs, it looks like I'm able to create a session now with a blank Chrome page (with "data:," in the address bar). Is this normal? Is the syntax of what I have thus far at least on the right track?? I appreciate the guidance! When it comes to this kind of stuff, I typically absorb information better working backwards by looking at an existing script and dissecting it to figure out what parts mean and such, so any previous post you can point me to that may have the most basic working script to simply launch Chrome and navigate to a webpage would be a great learning experience! #include <MsgBoxConstants.au3> #include <wd_core.au3> #include <wd_helper.au3> #include <wd_capabilities.au3> $_WD_DEBUG = $_WD_DEBUG_Error _WD_CapabilitiesStartup() _WD_CapabilitiesAdd("alwaysMatch", "chrome") _WD_CapabilitiesAdd("w3c", True) _WD_CapabilitiesAdd("excludeSwitches", "enable-automation") Local $sCapabilities = _WD_CapabilitiesGet() _WD_Option('Driver', 'chromedriver.exe') _WD_Option('Port', 9515) _WD_Startup() $sSession = _WD_CreateSession($sCapabilities) _WD_Navigate($sSession, "www.google.com") Console: >Running:(3.3.16.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\temp\AutoIT\test.au3" +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. __WD_Post ==> Invalid argument (5) HTTP status = 400 : ResponseText={"value":{"error":"invalid argument","message":"invalid argument\n (Session info: chrome=101.0.4951... _WD_Navigate ==> Invalid argument (5) HTTP status = 400 : {"value":{"error":"invalid argument","message":"invalid argument\n (Session info: chrome=101.0.4951.54)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00517413+2389011]\n\tOrdinal0 [0x004A9F61+1941345]\n\tOrdinal0 [0x0039C520+836896]\n\tOrdinal0 [0x0038E019+778265]\n\tOrdinal0 [0x0038CB9F+773023]\n\tOrdinal0 [0x0038CE6D+773741]\n\tOrdinal0 [0x0039DE5A+843354]\n\tOrdinal0 [0x003F49BD+1198525]\n\tOrdinal0 [0x003E414C+1130828]\n\tOrdinal0 [0x003F4302+1196802]\n\tOrdinal0 [0x003E3F66+1130342]\n\tOrdinal0 [0x003BE546+976198]\n\tOrdinal0 [0x003BF456+980054]\n\tGetHandleVerifier [0x006C9632+1727522]\n\tGetHandleVerifier [0x0077BA4D+2457661]\n\tGetHandleVerifier [0x005AEB81+569713]\n\tGetHandleVerifier [0x005ADD76+566118]\n\tOrdinal0 [0x004B0B2B+1968939]\n\tOrdinal0 [0x004B5988+1989000]\n\tOrdinal0 [0x004B5A75+1989237]\n\tOrdinal0 [0x004BECB1+2026673]\n\tBaseThreadInitThunk [0x76706359+25]\n\tRtlGetAppContainerNamedObjectPath [0x776287D4+228]\n\tRtlGetAppContainerNamedObjectPath [0x776287A4+180]\n"}} +>11:27:32 AutoIt3.exe ended.rc:0 +>11:27:33 AutoIt3Wrapper Finished. >Exit code: 0 Time: 15.32 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