Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

Did you run it from a network drive?

I updated to the latest WinHTTP version and there were no changes (other than the updated version in the output)

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

Weird. I'm going to chalk this up to a network drive over VPN and a Windows issue. Thanks for checking!

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

Do you see error messages as described here in your chrome.log?

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

No, there are no error messages in the log or in the DOS window that appears. And the strange thing is that the DOS window has the path of the driver in my documents folder

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

I occasionally get an issue with _WD_IsLatestRelease during _WD_Startup. The console says:

wd_helper.au3" (1127) : ==> Subscript used on non-accessible variable.:
Local $sLatestWDVersion = $aLatestWDVersion[0]
Local $sLatestWDVersion = $aLatestWDVersion^ ERROR

It looks like the GitHub page is being pulled by __WD_Get, but it's blank? I'll write it to a temp file the next time it happens.

Edit: That didn't take long. Looks like work is messing with my URLs. It pulls a URL like this instead: https://abc-nsd-dc-wsf-p-42/B0002D0000N0002N0000F0000S0000R0004/<IPAddress--removed>/https://github.com/Danp2/WebDriver/releases/latest, which of course doesn't have the latest version of the GitHub page... it tells me to contact my network admin

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

Hello everyone, this is my first post here! I just wanted some guidance regarding the Webdriver for Chrome. I found this video on youtube that showed the use of a demo script:

I've been trying to use just the first part, where it navigates to the website:

----- 

#include "wd_core.au3"
#include "wd_helper.au3"

 Local $sDesiredCapabilities
 local $sSession

 SetupChrome()

 _WD_Startup()
 $sSession = _WD_CreateSession($sDesiredCapabilities)
 _WD_Navigate($sSession, "https://www.facebook.com")

 _WD_Shutdown()

;Start webdriver for Chrome
Func SetupChrome()
_WD_Option('Driver', 'C:\WebDriver\chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": , "args":[' & """start-maximized""," & " ""disable-infobars""" & "" & ']}}}}'
EndFunc

----

However, it gives me this error message:

-----

_WDStartup: OS:    WIN_10 WIN32_NT 15063 
_WDStartup: AutoIt:    3.3.14.5
_WDStartup: WD.au3:    0.2.0.6
_WDStartup: WinHTTP:    1.6.4.1
_WDStartup: Driver:    C:\WebDriver\chromedriver.exe
_WDStartup: Params:    --log-path="C:\Program Files (x86)\AutoIt3\Include\chrome.log"
_WDStartup: Port:    9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": , "args":["start-maximized", "disable-infobars"]}}}}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CD5F73+2449267]\n\tOrdinal0 [0x00C08361+1606497]\n\tOrdinal0 [0x00AFF969+522601]\n\tOrdinal0 [0x00AA8904+166148]\n\tOrdinal0 [0x00AA85D4+165332]\n\tOrdinal0 [0x00A8232E+9006]\n\tOrdinal0 [0x00A82766+10086]\n\tOrdinal0 [0x00A82E30+11824]\n\tOrdinal0 [0x00C1D8D7+1693911]\n\tGetHandleVerifier [0x00D74036+522726]\n\tGetHandleVerifier [0x00D73D74+522020]\n\tGetHandleVerifier [0x00D89187+609079]\n\tGetHandleVerifier [0x00D748A6+524886]\n\tOrdinal0 [0x00C15CBC+1662140]\n\tOrdinal0 [0x00A821E2+8674]\n\tOrdinal0 [0x00A81F26+7974]\n\tGetHandleVerifier [0x00F8357C+2682668]\n\tBaseThreadInitThunk [0x74B28744+36]\n\tRtlGetAppContainerNamedObjectPath [0x77BE58ED+253]\n\tRtlGetAppContainerNamedObjectPath [0x77BE58BD+205]\n"}}
_WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CD5F73+2449267]\n\tOrdinal0 [0x00C08361+1606497]\n\tOrdinal0 [0x00AFF969+522601]\n\tOrdinal0 [0x00AA8904+166148]\n\tOrdinal0 [0x00AA85D4+165332]\n\tOrdinal0 [0x00A8232E+9006]\n\tOrdinal0 [0x00A82766+10086]\n\tOrdinal0 [0x00A82E30+11824]\n\tOrdinal0 [0x00C1D8D7+1693911]\n\tGetHandleVerifier [0x00D74036+522726]\n\tGetHandleVerifier [0x00D73D74+522020]\n\tGetHandleVerifier [0x00D89187+609079]\n\tGetHandleVerifier [0x00D748A6+524886]\n\tOrdinal0 [0x00C15CBC+1662140]\n\tOrdinal0 [0x00A821E2+8674]\n\tOrdinal0 [0x00A81F26+7974]\n\tGetHandleVerifier [0x00F8357C+2682668]\n\tBaseThreadInitThunk [0x74B28744+36]\n\tRtlGetAppContainerNamedObjectPath [0x77BE58ED+253]\n\tRtlGetAppContainerNamedObjectPath [0x77BE58BD+205]\n"}}
_WD_CreateSession ==> Webdriver Exception: invalid argument: missing command parameters
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"https://www.facebook.com"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CD5F73+2449267]\n\tOrdinal0 [0x00C08361+1606497]\n\tOrdinal0 [0x00AFF812+522258]\n\tOrdinal0 [0x00A91949+72009]\n\tOrdinal0 [0x00AA9F27+171815]\n\tOrdinal0 [0x00AA89FA+166394]\n\tOrdinal0 [0x00AA85D4+165332]\n\tOrdinal0 [0x00A8232E+9006]\n\tOrdinal0 [0x00A82766+10086]\n\tOrdinal0 [0x00A82E30+11824]\n\tOrdinal0 [0x00C1D8D7+1693911]\n\tGetHandleVerifier [0x00D74036+522726]\n\tGetHandleVerifier [0x00D73D74+522020]\n\tGetHandleVerifier [0x00D89187+609079]\n\tGetHandleVerifier [0x00D748A6+524886]\n\tOrdinal0 [0x00C15CBC+1662140]\n\tOrdinal0 [0x00A821E2+8674]\n\tOrdinal0 [0x00A81F26+7974]\n\tGetHandleVerifier [0x00F8357C+2682668]\n\tBaseThreadInitThunk [0x74B28744+36]\n\tRtlGetAppContainerNamedObjectPath [0x77BE58ED+253]\n\tRtlGetAppContainerNamedObjectPath [0x77BE58BD+205]\n"}}
_WD_Navigate: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CD5F73+2449267]\n\tOrdinal0 [0x00C08361+1606497]\n\tOrdinal0 [0x00AFF812+522258]\n\tOrdinal0 [0x00A91949+72009]\n\tOrdinal0 [0x00AA9F27+171815]\n\tOrdinal0 [0x00AA89FA+166394]\n\tOrdinal0 [0x00AA85D4+165332]\n\tOrdinal0 [0x00A8232E+9006]\n\tOrdinal0 [0x00A82766+10086]\n\tOrdinal0 [0x00A82E30+11824]\n\tOrdinal0 [0x00C1D8D7+1693911]\n\tGetHandleVerifier [0x00D74036+522726]\n\tGetHandleVerifier [0x00D73D74+522020]\n\tGetHandleVerifier [0x00D89187+609079]\n\tGetHandleVerifier [0x00D748A6+524886]\n\tOrdinal0 [0x00C15CBC+1662140]\n\tOrdinal0 [0x00A821E2+8674]\n\tOrdinal0 [0x00A81F26+7974]\n\tGetHandleVerifier [0x00F8357C+2682668]\n\tBaseThreadInitThunk [0x74B28744+36]\n\tRtlGetAppContainerNamedObjectPath [0x77BE58ED+253]\n\tRtlGetAppContainerNamedObjectPath [0x77BE58BD+205]\n"}}
>Exit code: 0    Time: 0.9342


-----

Not exactly sure in regards to what to do, since it works for the person on the video, I'm getting the feeling that there's something wrong on my end.

 

 

Link to comment
Share on other sites

I want to detect some href attribute of several a el, inside div blocks, so first I detect the divs, then I use el as $sStartElement.
But it doesn't work: it returns always the first a element from the beginning, it seems it ignores the $sStartElement

example simplified HTML: 

<div data-asin="xxxx">
    ....
    <a href="...1°../dp/......."></a>
    ....
</div>
.....
<div data-asin="xxxx">
    ....
    <a href="...2°../dp/......."></a>
    ....
</div>

 

$oEls = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@data-asin]", Default, true)

    For $i=0 to UBound($oEls)-1
            local $oLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[contains(@href,'/dp/')]", $oEls[$i] )
            ConsoleWrite("@@@@@@@@@@@@@@" & $oLink & @CRLF)
    Next


For example I get:

1° div $sStartElement:
__WD_Post: URL=HTTP://127.0.0.1:9515/session/9a737fa893882ebff734ac32f53f1228/element/efe5d6de-32a6-4200-aa0b-6047c68bf095/element; $sData={"using":"xpath","value":"//a[contains(@href,'/dp/')]"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"977286f3-53a5-4a79-85cd-fbd2c5a19ddb"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"977286f3-53a5-4a79-85cd-fbd2c5a19ddb"}}
@@@@@@@@@@@@@@977286f3-53a5-4a79-85cd-fbd2c5a19ddb

3° div $sStartElement:
__WD_Post: URL=HTTP://127.0.0.1:9515/session/9a737fa893882ebff734ac32f53f1228/element/b0e4173d-8c43-41b5-96ba-a4b7ebc655ff/element; $sData={"using":"xpath","value":"//a[contains(@href,'/dp/')]"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"977286f3-53a5-4a79-85cd-fbd2c5a19ddb"}}
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"977286f3-53a5-4a79-85cd-fbd2c5a19ddb"}}
@@@@@@@@@@@@@@977286f3-53a5-4a79-85cd-fbd2c5a19ddb


always the same a element 977286f3-53a5-4a79-85cd-fbd2c5a19ddb

How to solve this?

Edited by frank10
Link to comment
Share on other sites

This is a test version on a test page on Amazon.com

I need it to be only on Chrome.

#include "wd_helper.au3"
#include "wd_core.au3"

OnAutoItExitRegister("_onExit")

Local $sDesiredCapabilities

$_WD_DEBUG = True ; visible
;~ $_WD_DEBUG = $_WD_DEBUG_None ; You could also use $_WD_DEBUG_Error
;~ You can also control the visibility of the console with the function _WD_ConsoleVisible.

_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path=' & @ScriptDir & '\chrome.log')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}'

_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Window($sSession, "Maximize")

If @error = $_WD_ERROR_Success Then
    _WD_Navigate($sSession, "https://www.amazon.com/s?k=guide+to+investing+crypto&i=digital-text&page=2&qid=1587374511&ref=sr_pg_2")
    $firstTab = _WD_Window($sSession, 'Window')

    _WD_LoadWait($sSession)

    $oEls = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@data-asin]", Default, true)

    For $i=0 to UBound($oEls)-1
            local $oLink = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[contains(@href,'/dp/')]", $oEls[$i] )
            $sHref = _WD_ElementAction($sSession, $oLink, "Attribute", "href")
            ConsoleWrite("@@@@@@@@@@@@@@ " & $oLink & " ___" & $sHref & @CRLF)
    Next
EndIf

Func _onExit()
    _WD_DeleteSession($sSession)
    _WD_Shutdown()
EndFunc

 

Edited by frank10
Link to comment
Share on other sites

So, any idea how can I workaround it to get my <a>?

I could select all the a with /dp/ on href, but I need to discard some of them and I need to dig also inside the div parent to check some other properties.

For example I want to discard the ones that belongs to a div that is "Sponsored" and so on.

Edited by frank10
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...