Jump to content

Recommended Posts

Posted (edited)
#cs ----------------------------------------------------------------
Name ..........: ignore.au3
Description ...: Testing _WD_HighlightElements
SciTE 32-bit ..: Version 4.4.6
Author(s) .....: Thomas E. Bennett
Date ..........: 20220929

Recommended Reading / Requirements
https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-01162021/#comments
https://www.autoitscript.com/wiki/WebDriver
https://www.autoitscript.com/wiki/WebDriver#Installation
https://www.autoitscript.com/wiki/Adding_UDFs_to_AutoIt_and_SciTE
https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine
wd_core.au3
wd_helper.au3

From wd_core.au3
Global Const $_WD_LOCATOR_ByCSSSelector = "css selector"
Global Const $_WD_LOCATOR_ByXPath = "xpath"
Global Const $_WD_LOCATOR_ByLinkText = "link text"
Global Const $_WD_LOCATOR_ByPartialLinkText = "partial link text"
Global Const $_WD_LOCATOR_ByTagName = "tag name"
#ce ----------------------------------------------------------------

#include "wd_core.au3"
#include "wd_helper.au3"
#include "wd_cdp.au3"
#include "wd_capabilities.au3"
#include <MsgBoxConstants.au3>

Local $sDesiredCapabilities, $sElement, $sSession

Func SetupChrome()
; Google Chrome
_WD_Option('Driver', @ScriptDir & "\include\chromedriver.exe")

_WD_Option('Port', 9515)
;_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _
    '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
    '"prefs": {"credentials_enable_service": false},' & _
    '"args": ["start-maximized"] }}}}'
EndFunc

SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

Sleep (15000)

; DuckDuckGo
_WD_Navigate($sSession, "https://duckduckgo.com/")
_WD_LoadWait($sSession, 2000)

; Find the Search field
_WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='search_form_input_homepage']")
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='search_form_input_homepage']")
; Highlight the Search field
_WD_HighlightElements($sSession, $sElement, 3)
MsgBox(0,"","")

Exit ;this is here on purpose

_WD_DeleteSession($sSession)
_WD_Shutdown()
Exit

Good evening, everyone, 

I am trying to get any element to highlight using the _WD_HighlightElements function; I've tried different elements and for a time I thought maybe because I am working in Windows 11 so I switched back to Windows 10 same issue; I can't get the found element to highlight. What am I doing incorrectly?

Console Output

_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"0e212d4f-8437-42a0-a56a-bc8694fe6e66"}}
_WD_WaitElement ==> Success
__WD_Post: URL=HTTP://127.0.0.1:9515/session/0e05f8ea99dba06bb84908b0b46fe881/element; $sData={"using":"xpath","value":"//input[@id='search_form_input_homepage']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"0e212d4f-8437-42a0-a56a-bc8694fe6e66"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"0e212d4f-8437-42a0-a56a-bc8694fe6e66"}}

Thank you for your time on this,




Thomas E. Bennett

Edited by ThomasBennett
Added the console output
Posted

I tweaked your script, but it works as expected for me. Here's the revised code --

#cs ----------------------------------------------------------------
Name ..........: ignore.au3
Description ...: Testing _WD_HighlightElements
SciTE 32-bit ..: Version 4.4.6
Author(s) .....: Thomas E. Bennett
Date ..........: 20220929

Recommended Reading / Requirements
https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-01162021/#comments
https://www.autoitscript.com/wiki/WebDriver
https://www.autoitscript.com/wiki/WebDriver#Installation
https://www.autoitscript.com/wiki/Adding_UDFs_to_AutoIt_and_SciTE
https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine
wd_core.au3
wd_helper.au3

From wd_core.au3
Global Const $_WD_LOCATOR_ByCSSSelector = "css selector"
Global Const $_WD_LOCATOR_ByXPath = "xpath"
Global Const $_WD_LOCATOR_ByLinkText = "link text"
Global Const $_WD_LOCATOR_ByPartialLinkText = "partial link text"
Global Const $_WD_LOCATOR_ByTagName = "tag name"
#ce ----------------------------------------------------------------

#include "wd_core.au3"
#include "wd_helper.au3"
#include "wd_cdp.au3"
#include "wd_capabilities.au3"
#include <MsgBoxConstants.au3>

Local $sDesiredCapabilities, $sElement, $sSession

SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

; DuckDuckGo
_WD_Navigate($sSession, "https://duckduckgo.com/")
_WD_LoadWait($sSession, 2000)

; Find the Search field
$sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='search_form_input_homepage']")

; Highlight the Search field
_WD_HighlightElements($sSession, $sElement, 3)

Exit ;this is here on purpose

_WD_DeleteSession($sSession)
_WD_Shutdown()
Exit

Func SetupChrome()
; Google Chrome
_WD_Option('Driver', @ScriptDir & "\chromedriver.exe")

_WD_Option('Port', 9515)
;_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _
    '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
    '"prefs": {"credentials_enable_service": false},' & _
    '"args": ["start-maximized"] }}}}'
EndFunc

Your console output should look similar to this --

+>20:34:56 Starting AutoIt3Wrapper (22.611.2153.6) from:Code.exe (1.71.2.0)  Keyboard:00000409  OS:WIN_11/2009  CPU:X64 OS:X64  Environment(Language:0409)
>Running AU3Check (3.3.16.1)  from:C:\Program Files (x86)\AutoIt3  input:c:\GitHub\WebDriver\test.au3
+>20:34:57 AU3Check ended. rc:0
>Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "c:\GitHub\WebDriver\test.au3"  /errorstdout
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart. --> Press Ctrl+BREAK to Stop.
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=c:\GitHub\WebDriver\chromedriver.exe
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=9515
_WD_IsLatestRelease ==> Success [0] : False
_WD_Startup: OS:    WIN_11 WIN32_NT 22000 
_WD_Startup: AutoIt:    3.3.16.1
_WD_Startup: Webdriver UDF: 0.10.0 (Update available)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    c:\GitHub\WebDriver\chromedriver.exe (32 Bit)
_WD_Startup: Params:    
_WD_Startup: Port:  9515
_WD_Startup: Command:   "c:\GitHub\WebDriver\chromedriver.exe"  
_WD_Startup ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_CreateSession ==> Success [0] : 8177ff8e00c746289891af81fda8ee53
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Navigate ==> Success [0] : Parameters:   URL=https://duckduckgo.com/
_WD_LoadWait ==> Success [0] : Parameters:    Delay=2000    Timeout=Default    Element=Default
_WD_WaitElement ==> Success [0] : Parameters:   Strategy=xpath   Selector=//input[@id='search_form_input_homepage']   Delay=Default   Timeout=Default   Options=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_ExecuteScript ==> Success [0]
_WD_HighlightElements ==> Success [0] : Parameters:    Element=61288fe7-3e50-4d7d-a9c1-28df2d799d84    Method=3
+>20:35:05 AutoIt3 ended. rc:0
+>20:35:05 AutoIt3Wrapper Finished.
Process exited with code 0

Please post the full console output so that we can have the complete picture. 😉

Posted (edited)

Good evening, @Danp2

Console Output

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\thomas.bennett\{Privacy}\Knowledge\AutoIt\Please Note!\ignore.au3" /UserParams    
+>21:02:58 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000409  OS:WIN_10/2009  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\thomas.bennett\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\thomas.bennett\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.14.5)  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\thomas.bennett\{Privacy}\Knowledge\AutoIt\Please Note!\ignore.au3
+>21:02:59 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\thomas.bennett\{Privacy}\Knowledge\AutoIt\Please Note!\ignore.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
_WD_IsLatestRelease: 
_WD_IsLatestRelease ==> Webdriver Exception
_WD_Startup: OS:    WIN_10 WIN32_NT 22000 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.5.0.3 (Update status unknown [10])
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    C:\Users\thomas.bennett\{Privacy}\Knowledge\AutoIt\include\chromedriver.exe
_WD_Startup: Params:    
_WD_Startup: Port:  9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", "goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, "prefs": {"credentials_enable_service": false},"args": ["start-maximized"] }}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"105.0...
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"105.0.5195.127","chrome":{"chromedriverVersion":"105.0.5195.52 (412c95e518836d8a7d97250d62b29c2ae6a26a85-refs/branch-heads/5195@{#853})","userDataDir":"C:\\Users\\THOMAS~1.BEN\\AppData\\Local\\Temp\\scoped_dir11924_761009925"},"goog:chromeOptions":{"debuggerAddress":"localhost:61895"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"ignore","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"66f2cb6293d593f523f22f1d0d680485"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/66f2cb6293d593f523f22f1d0d680485/url; $sData={"url":"https://duckduckgo.com/"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/66f2cb6293d593f523f22f1d0d680485/execute/sync; $sData={"script":"return document.readyState", "args":[]}
__WD_Post: StatusCode=200; ResponseText={"value":"complete"}...
_WD_ExecuteScript: {"value":"complete"}...
__WD_Post: URL=HTTP://127.0.0.1:9515/session/66f2cb6293d593f523f22f1d0d680485/element; $sData={"using":"xpath","value":"//input[@id='search_form_input_homepage']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"baeb24eb-04ea-4366-a2ed-81ebafcc3eaa"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"baeb24eb-04ea-4366-a2ed-81ebafcc3eaa"}}
_WD_WaitElement ==> Success
+>21:03:08 AutoIt3.exe ended.rc:0
+>21:03:08 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 10.31

Above is the output console; I am not seeing the highlight around the search box. 

image.thumb.png.fa6141e4d14e0590ab3c02cc5adc4121.png

This is back on the Windows 11 laptop; if that matters.

Thank you, 




Thomas

Edited by ThomasBennett
Forgot to note the operating system and updated some paths for privacy.
  • Solution
Posted (edited)

@ThomasBennett

try this:

#cs ----------------------------------------------------------------
Name ..........: ignore.au3
Description ...: Testing _WD_HighlightElements
SciTE 32-bit ..: Version 4.4.6
Author(s) .....: Thomas E. Bennett
Date ..........: 20220929

Recommended Reading / Requirements
https://www.autoitscript.com/forum/topic/191990-webdriver-udf-w3c-compliant-version-01162021/#comments
https://www.autoitscript.com/wiki/WebDriver
https://www.autoitscript.com/wiki/WebDriver#Installation
https://www.autoitscript.com/wiki/Adding_UDFs_to_AutoIt_and_SciTE
https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine
wd_core.au3
wd_helper.au3

From wd_core.au3
Global Const $_WD_LOCATOR_ByCSSSelector = "css selector"
Global Const $_WD_LOCATOR_ByXPath = "xpath"
Global Const $_WD_LOCATOR_ByLinkText = "link text"
Global Const $_WD_LOCATOR_ByPartialLinkText = "partial link text"
Global Const $_WD_LOCATOR_ByTagName = "tag name"
#ce ----------------------------------------------------------------

#include <MsgBoxConstants.au3>

#include "wd_helper.au3"
#include "wd_cdp.au3"
#include "wd_capabilities.au3"

Global $sSession

_Example()
Exit

Func _Example()
    Local $sDesiredCapabilities = SetupChrome()
    _WD_Startup()
    $sSession = _WD_CreateSession($sDesiredCapabilities)

    ; DuckDuckGo
    _WD_Navigate($sSession, "https://duckduckgo.com/")
    _WD_LoadWait($sSession, 2000)

    ; Find the Search field
    Local $sElement = _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='search_form_input_homepage']")
    ConsoleWrite("! " & @ScriptLineNumber & @CRLF)

    ; Highlight the Search field
    _WD_HighlightElements($sSession, $sElement, 3)
    ConsoleWrite("! " & @ScriptLineNumber & @CRLF)

    If $IDYES = MsgBox($MB_YESNO + $MB_TOPMOST + $MB_ICONQUESTION + $MB_DEFBUTTON1, "Question", _
            "Close sesion ?") Then
        _WD_DeleteSession($sSession)
        _WD_Shutdown()
    EndIf

EndFunc   ;==>_Example

Func SetupChrome()
    ; Google Chrome
    _WD_Option('Driver', @ScriptDir & "\chromedriver.exe")

    _WD_Option('Port', 9515)
    ;_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')

    Local $sDesiredCapabilities = _
            '{"capabilities": {"alwaysMatch": {"unhandledPromptBehavior": "ignore", ' & _
            '"goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false, ' & _
            '"prefs": {"credentials_enable_service": false},' & _
            '"args": ["start-maximized"] }}}}'
    Return $sDesiredCapabilities
EndFunc   ;==>SetupChrome

 

btw.
You are using old WD UDF version

Update them using:
https://github.com/Danp2/au3WebDriver/archive/refs/heads/master.zip

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 9/30/2022 at 2:08 AM, ThomasBennett said:

_WD_Startup: WD.au3:    0.5.0.3

Expand  

That is very outdated. Please update as requested by @mLipok. However, I wouldn't recommend using the link he provided because that that would include code that hasn't be officially released. You can always find the latest "released" code at https://github.com/Danp2/au3WebDriver/releases/latest.

Edited by Danp2
Posted (edited)
  On 9/30/2022 at 11:57 AM, Danp2 said:

You can always find the latest "released" code at https://github.com/Danp2/au3WebDriver/releases/latest.

Expand  

please remove the last dot from the URL

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 9/30/2022 at 1:18 PM, ThomasBennett said:

It's always the simple things.. 

Expand  

Yeah. I took us almost 2 years from https://github.com/Danp2/au3WebDriver/releases/tag/0.5.0.3 until today ;)

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 9/30/2022 at 1:27 PM, Danp2 said:

Suggest that you do the same.

Expand  

Done

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
×
×
  • Create New...