Jump to content

chrome driver tutorials


Recommended Posts

I am new here and to autoit but gone thru some basic videos so far
and looking to expand beyond those basics.

Can someone reply with links to good english tutorials showing how to use chrome or firefox ?

( open and close, navigate, get info etc) .

Secondly what are the includes, requirements for doing so.

Thirdly, give links to documents or get those downloads, and install. 

Thanks very much.

Link to comment
Share on other sites

thanks, i will try to go thru everything there.

in the meantime, i went to github and copied  JSON.au3 since it seemed it was required. 
but where do i save this file, since it is called by wd_core.au3, and it seems it is supposed to be in the same 
directory as WinAPIProc.au3, and it seems impossible to write the JSON.au3 file in that same directory.
my beginning script starts with 

#include-once
#include "..\autoit-includes\wd_core.au3"

wiith errors 

#include-once
#include <WinAPIProc.au3>
#include <JSON.au3> ; https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn
#include <WinHttp.au3> ; https://www.autoitscript.com/forum/topic/84133-winhttp-functions/

update: i seem to be making progress, i believe when i saved the file JSON it got saved as a .txt file,

which i have corrected. The next error os finding binarycall, which i will try to adjust next.

thanks by the way for your earlier reply, and feel free to make suggestions when you have time, lol.

I am an old guy, who used to program way back when, formerly consultant, business programming,

LBL in Berkeley, and Oracle/Informix 4gl programming ( 1970's,1980's)  etc. This is all new though.

update: 

i have in the autoit registry a string to my includes
that registry is at the level of Autoit v3 and has as its
Name: Include REG_SZ 
and has as its Value data C:\Users\Ed\Documents\autoit-includes;
and has no quotes no extra backslashes ( should it have?)

that include directory has these files so far :
binarycall,JSON,wd_core,wd_demo, wd_helper, WinHttp
all of them with Type Autoit v3 Script.

i have a script which begins 
#include-once
#include "..\autoit-includes\wd_core.au3"
#include "..\autoit-includes\wd_helper.aue"
#include "..\autoit-includes\JSON.au3"
 

running the script produces the editor opening the file WinHttp.au3
with this error:


Func _BinaryCall_GetProcAddress($Module, $Proc)
in red: "C:\Users\Ed\Documents\autoit-includes\WinHttp.au3"(13,48) : error: _BinaryCall_GetProcAddress() already defined.
    Local $Ret = DllCall($__BinaryCall_Kernel32dll, 'ptr', 'GetProcAddress', 'ptr', $Module, 'str', $Proc)
    If @Error Or Not $Ret[0] Then Return SetError(1, @Error, 0)
    Return $Ret[0]
EndFunc

suggestions?

 

 

Edited by edrosenthal
updating
Link to comment
Share on other sites

The Tools menu is dynamically built based on the extension of the file being edited.  Open an au3 file in the editor, then press CTRL+1 (Scite Config).  When editing an au3 file, you will also see a lot of other useful tools in the Tools menu.

Edited by TheXman
Link to comment
Share on other sites

ahhhh.  i was reading the config file, but i see it now opens... thanks!
i did set the Include in the registry, and also the editor. so i think i have that issue solved.

But see above where i am getting the GetProcAddress already defined.

script-calling-error.png

error-binary-calls.png

Edited by edrosenthal
updating
Link to comment
Share on other sites

Not sure where you got that winhttp.au3 file, but that is not what the contents should look like.

The latest version can be found HERE

Edited by TheXman
Link to comment
Share on other sites

If you follow the link I provided, download the latest zip file, 1.6.4.1, and put the contents (WinHttp.chm, WinHttp.au3, and WinHttpConstants.au3) in your include folder.

Link to comment
Share on other sites

Looks like the latest version of WinHttp.au3 (1.6.4.2) is not zipped up.  You will need to download the raw version or copy it from HERE.

Link to comment
Share on other sites

 

** resolved ** ( got a newer version of chrome driver)
and now i am also getting the log file. 

I think i will call it a good day, and more later!

ok i'm back! I got the newer version of WinHttp.au3 and now the script is at least syntax free. i will finish the day with two lil' questions 

i'm using this line to create a log file 
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log') 

but i do not get the log file when script ends, but i do see in the console ie;

the error 


_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WDStartup: OS:    WIN_10 WIN32_NT 18363 
_WDStartup: AutoIt:    3.3.14.5
_WDStartup: WD.au3:    0.3.0.8 (Up to date)
_WDStartup: WinHTTP:    1.6.4.2
_WDStartup: Driver:    chromedriver.exe
_WDStartup: Params:    --log-path=C:\Users\Ed\Documents\autoit-scripts\chrome.log
_WDStartup: Port:    9515
_WD_Startup ==> General Error: Error launching web driver!
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}
__WD_Post: StatusCode=0; ResponseText=WinHTTP request timed out before Webdriver...
__WD_Post ==> Send / Recv error: WinHTTP request timed out before Webdriver
_WD_CreateSession: WinHTTP request timed out before Webdriver

do i put the script to sleep or something to fix? or is there a way in the editor to reset the timeout?

Google Chrome is up to date
Version 85.0.4183.83 (Official Build) (64-bit)
 
comments from the author
; #INDEX# ===================================================================================
; Title ...............: WinHttp
; File Name............: WinHttp.au3
; File Version.........: 1.6.4.2
; Min. AutoIt Version..: v3.3.7.20
; Description .........: AutoIt wrapper for WinHTTP functions
; Author... ...........: trancexx, ProgAndy
; Dll .................: winhttp.dll, kernel32.dll
 
 
Edited by edrosenthal
Link to comment
Share on other sites

after i installed chromedriver ( correct version i think for my chrome browser version) i was unable to get to 

my own website because of "Privacy Errors". It was ok in Firefox though. But i believe there are still issues

like i've not seen before. Perhaps i should take chromedriver out of the PATH, and move it somewhere else
just for autoit? if so, where? I did have some errors running my script, 
here is the latest log file from launching the driver.

[1599517358.609][INFO]: Starting ChromeDriver 85.0.4183.87 (cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs/branch-heads/4183@{#1689}) on port 9515
[1599517358.609][INFO]: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
 

 

Link to comment
Share on other sites

i'm trying to follow example3 which begins

#Include <Array.au3>
#Include <Chrome.au3>


; Close any existing Chrome browser
_ChromeShutdown()

; Start Chrome with the URL "http://www.december.com/html/demo/form.html"
_ChromeStartup("http://www.december.com/html/demo/form.html")

; Wait for the page with the document title of "HTML Form Example"
_ChromeDocWaitForExistenceByTitle("HTML Form Example", 10)

; Set the value of the field labelled "Your age:" to "8"
_ChromeObjSetValueByName("user-age", "8")

the correct url opens, but nothing after that happens the way i believe it is supposed to.

the result in the console is 

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\Ed\Documents\autoit-scripts\chrome_example.au3" /UserParams    
+>10:08:31 Starting AutoIt3Wrapper (19.1127.1402.0} from:SciTE.exe (4.2.0.0)  Keyboard:00000409  OS:WIN_10/  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\Ed\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\Ed\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\Ed\Documents\autoit-scripts\chrome_example.au3
+>10:08:31 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Ed\Documents\autoit-scripts\chrome_example.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
_ChromeDocGetTitle() = 
_ChromeObjGetHTMLByTagName("h1") = 
_ChromeObjGetHTMLByTagName("p", 1) = 
_ChromeObjGetHTMLByTagName("p", 2) = 
_ChromeObjGetHTMLByTagName("p", 3) = 
_ChromeObjGetHTMLByTagName("p", 4) = 
_ChromeObjGetHTMLByTagName("p", 5) = 
_ChromeObjGetHTMLByTagName("p", 6) = 
_ChromeObjGetHTMLByTagName("p", 7) = 
_ChromeObjGetHTMLByTagName("p", 😎
_ChromeObjGetHTMLByTagName("p", 9) = 
+>10:10:34 AutoIt3.exe ended.rc:0
+>10:10:34 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 123.4
 

i'm trying to discover the correct way to navigate, so this does not enlighten me as to how 

to find objects and subject them to some sort of activity ie; setting text, or sending keys,
or even to find what is on the browser window correctly.
are there more workable examples to follow?

thanks in advance!

also, is there a help file for the command set either for the native (?) chromian driver, or for the UDF?

I'm guess here that the UDF is a wrapper to make things easier, but is it not also to avoid coding in the UDF
and use the chrome driver command set?

Or am i completely wrong in thinking this?

 

Edited by edrosenthal
Link to comment
Share on other sites

1 hour ago, Danp2 said:

o you've switched to using the Chrome UDF instead of the Webdriver UDF?

i will try to learn both, is possible to write hybrid ( both)? 
In the editor i can press F1 for non driver commands, is there a chm file somewhere for either of the others?

Link to comment
Share on other sites

Hi again, i feel i am getting lost before i even start. 
When i include code such as this - am i using the chrome driver with the webdriver UDF - 

and where is a list of webdriver UDF commands and its accompanying help file? 
thanks so much for sticking with me...

#include-once
#include "..\autoit-includes\wd_core.au3"
#include "..\autoit-includes\wd_helper.au3"
;#include "..\autoit-includes\JSON.au3"
Local $sDesiredCapailities, $sSession
SetupChrome()

_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapailities)
_WD_Navigate ($sSession, "https://constantcontact.com/")

_WD_LoadWait($sSession)
Sleep (5000)


$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "/html[1]/body[1]/div[1]/div[1]/header[1]/div[1]/ul[1]/li[2]")
$sText = _WD_ElementAction($sSession, $sElement, 'text')
MsgBox (0,"$sText",$sText)

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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