Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

  • Developers
2 minutes ago, lenclstr746 said:

how can i get chrome url ?

How often are you going to ask the same question?

Please do not crosspost and stick to a single post, posted at the correct place! (meaning not in the developers forum!)

Thanks,
Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@lenclstr746 Please remember that we all volunteer our time in these forums. We are here to provide assistance, but you need to make a reasonable effort on your part. Help us to help you by providing more details because my crystal ball is currently in the shop and I don't know how to fix "doesn't work" without more info. :rolleyes:

Link to comment
Share on other sites

@lenclstr746. First, you'd need to compile it. Choose 32bit or 64bit, then 'Compile Script'. That'll make an exe version of your scrip (in this case, wd_demo.exe). Now you can run it and click to toggle which "Demo" you like see.

I'm not sure which editor you're using. With SciTe editor, you would Ctrl+F7 to compile.

Once you've successfully compiled it the first time, you can now use Build (F7) to continue as you make changes to wd_demo.au3

------------------------------------------------------------

Now back to my own topic...

If  'ScriptDir' is used, where exactly is this location? I don't have a 'Script' folder in user profile.
Nevermind, I found out. However, I don't see anything like a default folder (Downloads) nor PicturesDir. Is it possible to create dir's?

Edited by Purity8
Found 'ScriptsDir' Location, editted for more info
Link to comment
Share on other sites

Perfect, thanks!

Well, Gecko seems to be making new profiles...perhaps that's why I had problems. The first time running a new profile in "Debug: None" mode will cause both console & browser to do nothing & display "Demo Complete", delete session & exit console.

Link to comment
Share on other sites

45 minutes ago, Purity8 said:

Gecko seems to be making new profiles

That's how Webdriver works, unless you give it directions to use an existing profile. See the FAQ section in the Wiki.

Quote

Would this work? 

Nope... because that isn't valid syntax. Did you click the hyperlink I posted earlier or look at the help file?

Link to comment
Share on other sites

Yeah, I did but I thought something like would work. I didn't want to use the full path...and it made sense in a way 😂.

In Desktop dir, create Pictures.

Ah well, was worth a try.

I know I gotta use $sFilePath.

Edited by Purity8
Link to comment
Share on other sites

Perfect, thanks a lot. You are working around the clock!

Can I also use the same 

'rect', '{"x":30,"y":30,"width":100,"height":100}')

in $sDesiredCapabilities? 

 

Edited by HJL
Link to comment
Share on other sites

14 hours ago, Danp2 said:

like this:

DirCreate(@DesktopDir & "/Pictures")

 

Well, I did try that. Nothing happened when I ran the script...

Oddly, I removed Func & EndFunc, and it worked.

 

edit:

With your reference, I managed to solve downloading files to Downloads folder. Thanks 😎

Edited by Purity8
Link to comment
Share on other sites

I'm not sure if this an issue with the UDF or with something else, but I noticed (after an hour of debugging) that a copy of the driver in the local directory can cause the UDF to fail.

I store my scripts at work on a network drive and wanted a copy of the driver stored in a central location to be able to copy... so my setup looks like this:

C:\Users\seadoggie\Documents\chromedriver.exe <-- a temporary file, will adjust to AppData later. Referenced in script

U:\Documents\AutoIt Files\Reports\myScript.au3
U:\Documents\AutoIt Files\Reports\chromedriver.exe <-- the driver to copy to user's computer

When there is a copy in the script's directory, _WD_CreateSession fails with Error 9 10 - $_WD_ERROR_Exception. Without a copy in the script's directory, everything works as expected. Maybe someone else can test this? It's strangely specific and it seems like I'm missing something important

Edited by seadoggie01
Updated to latest UDF version

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 functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

How do you reference the driver in your script? Did you have a look at the wiki -> FAQ #6?

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Yes, I have this in my script:

_WD_Option('Driver', @UserProfileDir & "\Documents\chromedriver.exe")

I moved the network copy to a sub-directory named Drivers and everything works now. If at any point I copy the driver back to the parent directory, _WD_CreateSession fails.

Edit: Reproducable code

Spoiler

 

#include <wd_core.au3>

Main()

Func Main()

    _WD_Option('Driver', @UserProfileDir & "\Documents\chromedriver.exe")
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path=' & @UserProfileDir & '\Documents\chrome.log')
    Local $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--profile-directory=Default"]}}}}'

    _WD_Startup()
    If @error Then Exit ConsoleWrite("_WD_Startup")

    Local $sSession = _WD_CreateSession($sDesiredCapabilities)
    If @error Then Exit ConsoleWrite("_WD_CreateSession Error: " & @error)

    _WD_DeleteSession($sSession)
    _WD_Shutdown()

EndFunc

 

 

Edited by seadoggie01

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 functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

 

_WDStartup: OS: WIN_10 WIN32_NT 17763 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.2.0.7
_WDStartup: WinHTTP:    1.6.4.1
_WDStartup: Driver: C:\Users\seadoggie\Documents\chromedriver.exe
_WDStartup: Params: --log-path=C:\Users\seadoggie\Documents\chrome.log
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--profile-directory=Default"]}}}}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_CreateSession: 0
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
_WD_CreateSession Error: 10

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 functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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