Jump to content

Recommended Posts

Posted

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.

Posted

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)

Posted

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)?

Posted

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??

Posted (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 by kornholeking
Posted

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?

Posted
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?

Posted

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.

Posted

@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')

     

Posted

@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

Posted
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

Posted

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

Posted

@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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...