Jump to content

WebDriver UDF - Help & Support (III)


Danp2
 Share

Recommended Posts

15 hours ago, Danp2 said:

@Blueman Unsure about the full screen mode detection. You may be able to do it with some javascript and _WD_ExecuteScript.

Hmm,.. 

Good idea, i will try that, thanks!

Edit: 
For all others searching for a solution;
I managed to perform the check like this, working perfectly, it can possibly be simplified so suggestions are welcome :) 
 

;Setting Vars
    local $JS_Scr_Height, $JS_Scr_Width, $JS_Scr_InnHeight, $JS_Scr_InnWidth

    ;Perform Get Data and act accordingly.
    $JS_Scr_Height = _WD_ExecuteScript($sSession, "return screen.height;")
    $JS_Scr_Height = Json_Decode($JS_Scr_Height)
    $JS_Scr_Width = _WD_ExecuteScript($sSession, "return screen.width;")
    $JS_Scr_Width = Json_Decode($JS_Scr_Width)
    $JS_Scr_InnHeight = _WD_ExecuteScript($sSession, "return screen.innerHeight;")
    $JS_Scr_InnHeight = Json_Decode($JS_Scr_InnHeight)
    $JS_Scr_InnWidth = _WD_ExecuteScript($sSession, "return screen.innerWidth;")
    $JS_Scr_InnWidth = Json_Decode($JS_Scr_InnWidth)

    If NOT (Json_Get($JS_Scr_Height, "[value]") == Json_Get($JS_Scr_InnHeight, "[value]") AND Json_Get($JS_Scr_Width, "[value]") == Json_Get($JS_Scr_InnWidth, "[value]")) Then
        ;Set Section back to FullScreen again
        _WD_Window($sSession, 'Fullscreen', '')
    EndIf

 

Edited by Blueman
Added code/solution
Link to comment
Share on other sites

Untested, but I think something like this would work --

Func _WD_IsFullscreen($sSession)
    Local Const $sFuncName = "_WD_IsFullScreen"
    Local $sResponse = _WD_ExecuteScript($sSession, 'return screen.width == window.innerWidth and screen.height == window.innerHeight;')

    If @error <> $_WD_ERROR_Success Then
        Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Exception), 0, $sResult)
    EndIf

    Local $oJSON = Json_Decode($sResponse)
    Local $bResult = Json_Get($oJSON, "[value]")

    Return SetError($_WD_ERROR_Success, 0, $bResult)
EndFunc

 

Edited by Danp2
Fix variable name
Link to comment
Share on other sites

@Nine Ah thanks, will change that :) (But this also worked ByTheWay 😇)

@Danp2 Nice Function, will test it over here (with 16 attached screens) and let you know 👍

@Danp2 Checked in live environment, but some remarks;
- Variable $sResult wasn't declared, so i added it to the top as Local Variable.
 

Func _WD_IsFullscreen($sSession)
    Local Const $sFuncName = "_WD_IsFullScreen"
    Local $sResult
    Local $sResponse = _WD_ExecuteScript($sSession, 'return screen.width == window.innerWidth and screen.height == window.innerHeight;')

    If @error <> $_WD_ERROR_Success Then
        Return SetError(__WD_Error($sFuncName, $_WD_ERROR_Exception), 0, $sResult)
    EndIf

    Local $oJSON = Json_Decode($sResponse)
    Local $bResult = Json_Get($oJSON, "[value]")

    Return SetError($_WD_ERROR_Success, 0, $bResult)
EndFunc


- Javascript throws an error; 

_WD_ExecuteScript: {"value":{"error":"javascript error","message":"javascript error: Unexpected identifier\n  (Session ...

I have tried several things, but my knowledge of Javascript is not that advanced that i can find the issue, maybe you can? 😉

 

Thanks!

Edited by Blueman
Link to comment
Share on other sites

I'm getting an error while using _WD_ElementActionEx:

Local $sTemp = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "./td[2]", $asTableRows[0])
If @error Then Return SetError(18, 0, False)

_WD_ElementActionEx($sSession, $sTemp, "rightclick")
If @error Then Return SetError(19, 0, False)

Console output:

_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"0c055d0e-5da9-411e-86b1-3a447da4f374"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session/2b1c6dc680ffa06ea9931ac6d388019e/actions; $sData={"actions":[{"id":"hover","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"0c055d0e-5da9-411e-86b1-3a447da4f374","element-6066-11e4-a52e-4f735466cecf":"0c055d0e-5da9-411e-86b1-3a447da4f374"}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]}]}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stack...
__WD_Post ==> Invalid argument: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x00007FF757EA5D02+4676866]\n\tOrdinal0 [0x00007FF757B4D6B7+1169079]\n\tOrdinal0 [0x00007FF757B9D2B0+1495728]\n\tOrdinal0 [0x00007FF757B280C9+1016009]\n\tOrdinal0 [0x00007FF757C20161+2031969]\n\tOrdinal0 [0x00007FF757BEC77E+1820542]\n\tOrdinal0 [0x00007FF757DC3274+3748468]\n\tOrdinal0 [0x00007FF757BED14E+1823054]\n\tOrdinal0 [0x00007FF757EB88C4+4753604]\n\tOrdinal0 [0x00007FF757B275D2+1013202]\n\tOrdinal0 [0x00007FF757DCDA78+3791480]\n\tBaseThreadInitThunk [0x00007FF92A9A7034+20]\n\tRtlUserThreadStart [0x00007FF92AC82651+33]\n"}}
_WD_Action: {"value":{"error":"invalid argument","message":"invalid argument: missing command parameters","stacktrace":"Backtrace:\n\tOrdinal0 [0x00007FF757EA5D02+4676866]\n\tOrdinal0 [0x00007FF757B4D6B7+1169079]\n\tOrdinal0 [0x00007FF757B9D2B0+1495728]\n\tOrdinal0 [0x00007FF757B280C9+1016009]\n\tOrdinal0 [0x00007FF757C20161+2031969]\n\tOrdinal0 [0x00007FF757BEC77E+1820542]\n\tOrdinal0 [0x00007FF757DC3274+3748468]\n\tOrdinal0 [0x00007FF757BED14E+1823054]\n\tOrdinal0 [0x00007FF757EB88C4+4753604]\n\tOrdinal0 [0x00007FF757B275D2+1013202]\n\tOrdinal0 [0x00007FF757DCDA78+3791480]\n\tBaseThreadInitThunk [0x00007FF92A9A7034+20]\n\tRtlUserThreadStart [0x00007FF92AC82651+33]\n"}}
_WD_Action ==> Invalid argument: HTTP status = 400
_WD_ElementActionEx ==> Invalid argument

I'm guessing that the action is being built incorrectly, but I'm really not great with reading/writing JSON. I think this was working in version 3.1.1

Edit: Looks to me like there are too many closing bracket/braces at the end?

Edit 2: Yes... too many closing items. I'm guessing due to this code:

; Close mouse actions
$sAction &= "]}"

If $sPostAction Then
$sAction &= $sPostAction
EndIf

; Close main action
$sAction &= "]}]}"

The main action likely only needs one set of ]} I think

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

good day everyone I have  a 2 questions:

1. Is it possible to wait for the frame to load in the page without sleep ?

2. why, after selecting all and pressing enter, does it not load everything ?

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <File.au3>
#include <Array.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>

Global $sDesiredCapabilities, $sSession, $sElement

SetupEdge()
_WD_Startup()
If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

$sSession = _WD_CreateSession($sDesiredCapabilities)
_ScrapeEconCalendar()


_WD_DeleteSession($sSession)
_WD_Shutdown()


Func _ScrapeEconCalendar()
    _WD_Navigate($sSession, "https://www.cboe.com/delayed_quotes/fxe/quote_table")

    ; Locate a single element
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='txtSymbol']")

    $sValue = _WD_ElementAction($sSession, $sElement, 'property', 'value')
    _WD_ElementAction($sSession, $sElement, 'clear')
    Sleep(5500)

    _WD_ElementAction($sSession, $sElement, 'value', "fxe")

    Sleep(5500)

    ; Locate a single element
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='select_5']")
    Sleep(500)
    ; Click input element
    _WD_ElementAction($sSession, $sElement, 'click')
    _WD_ElementAction($sSession, $sElement, 'value', "All")
    Sleep(500)
    Send("{ENTER}")

    Sleep(5500)
    ; Locate a single element
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[@class='Button__TextContainer-sc-1tdgwi0-1 jzZxHG']")
    _WD_ElementAction($sSession, $sElement, 'click')

    Sleep(5500)


    MsgBox(0, '', $sElement)

EndFunc   ;==>_ScrapeEconCalendar

Func SetupEdge()
    _WD_Option('Driver', 'msedgedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"')

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "' & StringReplace(@ProgramFilesDir, "\", "/") & '/Microsoft/Edge/Application/msedge.exe", "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false}}}}'
EndFunc   ;==>SetupEdge

thank you all

Link to comment
Share on other sites

Simply get page source.
If you have a specific need ... describe in more detail what you want to achieve.

 

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:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2023-04-24

Link to comment
Share on other sites

1 hour ago, mLipok said:

Simply get page source.
If you have a specific need ... describe in more detail what you want to achieve.

I did do view page source but not saw nothing  about a table  sorry

58 minutes ago, Danp2 said:

@Marlon13 What makes you think that Javascript generated HTML wouldn't be accessible using the standard Webdriver functions?

P.S. Your post was vague. If you need help, then be specific about what you are trying to accomplish, what you've tried thus far, etc. Help us to help you

sorry  this is  a  code I try to grab a table but nothing

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <File.au3>
#include <Array.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <Debug.au3>

Global $sDesiredCapabilities, $sSession, $sElement

SetupEdge()
_WD_Startup()
If @error <> $_WD_ERROR_Success Then
    Exit -1
EndIf

$sSession = _WD_CreateSession($sDesiredCapabilities)
_ScrapeEconCalendar()


_WD_DeleteSession($sSession)
_WD_Shutdown()


Func _ScrapeEconCalendar()
    ;_WD_Navigate($sSession, "https://www.cboe.com/delayed_quotes/fxe/quote_table")
    _WD_Navigate($sSession, "https://www.barchart.com/login")

    ; Locate a single element
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input [@name='email']")

    $sValue = _WD_ElementAction($sSession, $sElement, 'property', 'value')
    _WD_ElementAction($sSession, $sElement, 'clear')
    Sleep(500)
    _WD_ElementAction($sSession, $sElement, 'value', "xxxxxxxx")

    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input [@name='password']")
    $sValue = _WD_ElementAction($sSession, $sElement, 'property', 'value')
    _WD_ElementAction($sSession, $sElement, 'clear')
    Sleep(500)
    _WD_ElementAction($sSession, $sElement, 'value', "xxxxxxxx")
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//button[@type="submit"]')
    ; Click input element
    _WD_ElementAction($sSession, $sElement, 'click')
    ;Sleep(55500)

    ;_WD_WaitElement($sSession,$_WD_LOCATOR_ByXPath,"//input[@id='select_5']")
    ; Locate a single element
    ;$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class='ReactSelect__single-value css-1uccc91-singleValue'>Near the Money]")
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//input[@id="select_5"]')
    ;MsgBox(0, '$sElement', $sElement)
    Sleep(500)
    ; Click input element
    _WD_ElementAction($sSession, $sElement, 'click')
    _WD_ElementAction($sSession, $sElement, 'value', "All")
    Sleep(500)
    Send("{ENTER}")

    Sleep(5500)
    ; Locate a single element
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[@class='Button__TextContainer-sc-1tdgwi0-1 jzZxHG']")
    _WD_ElementAction($sSession, $sElement, 'click')

    Sleep(5500)
    _WD_Navigate($sSession, "https://www.barchart.com/etfs-funds/quotes/FXE/volatility-greeks?moneyness=allRows")
    Sleep(5500)
 Local $aResult = _WD_GetTable($sSession, "//div[@class='bc-datatable']")
_DebugArrayDisplay($aResult)


    MsgBox(0, '', $sElement)

EndFunc   ;==>_ScrapeEconCalendar

Func SetupEdge()
    _WD_Option('Driver', 'msedgedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"')

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "' & StringReplace(@ProgramFilesDir, "\", "/") & '/Microsoft/Edge/Application/msedge.exe", "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false}}}}'
EndFunc   ;==>SetupEdge

 

Link to comment
Share on other sites

@Danp2Dan,

I've been coding in AutoIt for several years with IE and have been learning to use your WebDriver UDF to adjust to MS Edge, Chrome, and Firefox. A few issues have come up:

1.  I've installed all the latest components to run wd_demo.au3 but it only works with Edge and Chrome. Selecting Firefox returns the following errors: (I've tried editing the capabilities string to include the binary path but that doesn't work either)

_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WD_Startup: OS: WIN_10 WIN32_NT 19041
_WD_Startup: AutoIt: 3.3.14.5
_WD_Startup: WD.au3: 0.4.0.3 (Up to date)
_WD_Startup: WinHTTP: 1.6.4.2
_WD_Startup: Driver: geckodriver.exe
_WD_Startup: Params: --log trace
_WD_Startup: Port: 4444
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session; $sData={"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}
__WD_Post: StatusCode=500; ResponseText={"value":{"error":"session not created","message":"Expected browser binary location, but unable to f...
__WD_Post ==> Webdriver Exception: {"value":{"error":"session not created","message":"Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line","stacktrace":""}}
_WD_CreateSession: {"value":{"error":"session not created","message":"Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line","stacktrace":""}}
_WD_CreateSession ==> Webdriver Exception: HTTP status = 500
__WD_Delete: URL=HTTP://xxx.x.x.x:xxx/session/
__WD_Delete: StatusCode=405; ResponseText=HTTP method not allowed...
_WD_DeleteSession: HTTP method not allowed

2. The Wiki on WebDriver has some instruction on using existing profiles to load Firefox & Chrome but not MS Edge. When I change the single capabilities line in the wd_demo3.au for edge to: $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"args": ["user-data-dir=C:\\Users\\MyName\\AppData\\Local\\Microsoft\\Edge\\User Data", "profile-directory=Profile 1"]}}}}'

MS Edge will load with my existing profile but it can no longer execute _WD_NewTab($sSession, Default, Default, "http://yahoo.com") in the shortened DemoNavigation. I edited the demo to just demonstrate the behavior and shorten the error reporting.  Is there a method to load the Edge webdriver and still have _WD_NewTab() function as expected? I've tried numerous edits of the capabilities string to have the binary path as in the original wd_demo.au3, adding only the args for the profile, but those attempts failed as well.

Func DemoNavigation()
    _WD_Navigate($sSession, "http://google.com")
    _WD_NewTab($sSession, Default, Default, "http://yahoo.com")

    ConsoleWrite("URL=" & _WD_Action($sSession, 'url') & @CRLF)
    _WD_Attach($sSession, "google.com", "URL")
    ConsoleWrite("URL=" & _WD_Action($sSession, 'url') & @CRLF)
    _WD_Attach($sSession, "yahoo.com", "URL")
    ConsoleWrite("URL=" & _WD_Action($sSession, 'url') & @CRLF)
EndFunc   ;==>DemoNavigation

Func SetupEdge()
    _WD_Option('Driver', 'msedgedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\msedge.log"')

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"args": ["user-data-dir=C:\\Users\\MyName\\AppData\\Local\\Microsoft\\Edge\\User Data", "profile-directory=Profile 1"]}}}}'
;~  $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"binary": "' & StringReplace(@ProgramFilesDir, "\", "/") & '/Microsoft/Edge/Application/msedge.exe", "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false}}}}'
EndFunc   ;==>SetupEdge


_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WD_Startup: OS:    WIN_10 WIN32_NT 19041 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.0.3 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    msedgedriver.exe
_WD_Startup: Params:    --verbose --log-path="C:\Users\MyName\Desktop\AutoIt\msedge.log"
_WD_Startup: Port:  9515
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session; $sData={"capabilities": {"alwaysMatch": {"ms:edgeOptions": {"args": ["user-data-dir=C:\\Users\\MyName\\AppData\\Local\\Microsoft\\Edge\\User Data", "profile-directory=Profile 1"]}}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"msedge","browserVersion":"90.0....
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"msedge","browserVersion":"90.0.818.49","ms:edgeOptions":{"debuggerAddress":"localhost:53675"},"msedge":{"msedgedriverVersion":"90.0.818.49 (386cfd3fb45b9f4497bdaca497427868912f676a)","userDataDir":"C:\\Users\\MyName\\AppData\\Local\\Microsoft\\Edge\\User Data"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"4bfcdeb9775bfce898020b8240be5fb9"}}
Bypass: DemoTimeouts
+Running: DemoNavigation
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/url; $sData={"url":"http://google.com"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}...
_WD_Window: {"value":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}...
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/window/new; $sData={"type":"tab"}
__WD_Post: StatusCode=500; ResponseText={"value":{"error":"unknown error","message":"unknown error: unhandled inspector error: {\"code\":-32...
__WD_Post ==> Webdriver Exception: {"value":{"error":"unknown error","message":"unknown error: unhandled inspector error: {\"code\":-32000,\"message\":\"Failed to open new tab - no browser is open\"}\n  (Session info: MicrosoftEdge=90.0.818.49)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00677A53+3570259]\n\tOrdinal0 [0x0039851C+558364]\n\tOrdinal0 [0x0038B58E+505230]\n\tOrdinal0 [0x0038B757+505687]\n\tOrdinal0 [0x00384AA5+477861]\n\tOrdinal0 [0x003E0374+852852]\n\tOrdinal0 [0x003D3063+798819]\n\tOrdinal0 [0x003DF7A2+849826]\n\tOrdinal0 [0x003D2F2B+798507]\n\tOrdinal0 [0x003B6C4F+683087]\n\tOrdinal0 [0x003B794A+686410]\n\tOrdinal0 [0x003B78E7+686311]\n\tOrdinal0 [0x0058169C+2561692]\n\tGetHandleVerifier [0x0079074F+1041231]\n\tGetHandleVerifier [0x0079E294+1097364]\n\tGetHandleVerifier [0x0079112B+1043755]\n\tOrdinal0 [0x0057952F+2528559]\n\tOrdinal0 [0x00583148+2568520]\n\tOrdinal0 [0x005832DB+2568923]\n\tOrdinal0 [0x00594E1A+2641434]\n\tBaseThreadInitThunk [0x7791FA29+25]\n\tRtlGetAppContainerNamedObjectPath [0x77CC7A4E+286]\n\tRtlGetAppContainerNamedObjectPath [0x77CC7A1E+238]\n"}}
_WD_Window: {"value":{"error":"unknown error","message":"unknown error: unhandled inspector error: {\"code\":-32...
_WD_Window ==> Webdriver Exception: HTTP status = 500
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.google.com/"}...
_WD_Action: {"value":"https://www.google.com/"}
URL=https://www.google.com/
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"]}...
_WD_Window: {"value":["CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"]}...
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}...
_WD_Window: {"value":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}...
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/window; $sData={"handle":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.google.com/"}...
_WD_Action: {"value":"https://www.google.com/"}
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.google.com/"}...
_WD_Action: {"value":"https://www.google.com/"}
URL=https://www.google.com/
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/window/handles
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":["CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"]}...
_WD_Window: {"value":["CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"]}...
__WD_Get: URL=HTTP://127.0.0.1:9515/session/4bfcdeb9775bfce898020b8240be5fb9/window
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}...
_WD_Window: {"value":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}...
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/window; $sData={"handle":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.google.com/"}...
_WD_Action: {"value":"https://www.google.com/"}
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/window; $sData={"handle":"CDwindow-5062B069E540C96CBB334C0EAFB2A2FB"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Window: {"value":null}...
_WD_Attach ==> No match
__WD_Get: URL=HTTP://xxx.x.x.x:xxx/session/4bfcdeb9775bfce898020b8240be5fb9/url
__WD_Get: StatusCode=200; $iResult = 0; $sResponseText={"value":"https://www.google.com/"}...
_WD_Action: {"value":"https://www.google.com/"}
URL=https://www.google.com/
+Finished: DemoNavigation
Bypass: DemoElements
Bypass: DemoScript
Bypass: DemoCookies
Bypass: DemoAlerts
Bypass: DemoFrames
Bypass: DemoActions
Bypass: DemoDownload
Bypass: DemoWindows
Bypass: DemoUpload

 

3. Finally, I resorted to using Chrome with webdriver as the other two browsers were having issues. Any scripts that I wrote and worked for Edge to "click" a web button or input would NOT work for Chrome. After many hours of banging my head, web searching, and debugging, the issue seems to be a persistent bug with the Chrome webdriver that will not click properly if the zoom level is set to anything other than 100%, which unfortunately, I cannot use because the private web pages that I work with will only display all the information with zoom levels of at least 80%.

So with the above issues, I'm kinda stuck..Can't load Firefox (maybe it needs the MS Visual Studio runtime that I don't have), can't run Edge with my profile and not use _WD_NewTab(), and Chrome won't operate as other browsers do with Zoom not set to 100%.

Edited by CodeWriter
Link to comment
Share on other sites

@CodeWriter

#1 has been previously discussed on this forum. You can find the prior discussions by using the forum search feature to locate the phrase "Expected browser binary location"

#2 This isn't something that I've encountered. Looking at the results, this may be an issue with the MSEdgeDriver. To confirm, you're stating that the _WD_NewTab executes properly when not utilizing an existing profile, correct?

#3 Haven't encountered this either because I generally run @ 100%. Can you provide a short reproducer that uses a public website?

FWIW, I know that some folks are having issues with Chrome 90.x and webdriver. See here for more details. It's possible that MSEdge is suffering from some of these same issues.

Link to comment
Share on other sites

@Danp2

1. I've tried the binary path route for Firefox but no love. I'd be happy to post you the details and error logs when the binary path is added.

2. Yes. _WD_NewTab() works as expected when loading Edge without a profile. With a profile, it doesn't work.

3. Here is a short edited version of your wd_demo.au3 that will load www.google.com and enter a search that works at 100%. When you change the zoom to anything less than 100% (the capabilities string has been added so that the next time you run the code, the zoom level will stay), the search button click no longer works.

#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>

Local $sDesiredCapabilities, $sSession
SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
clickTest()
Sleep(15000)
_WD_DeleteSession($sSession)
_WD_Shutdown()

Func clickTest()
    _WD_Navigate($sSession, "http://google.com")
    $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='q']")
    _WD_ElementAction($sSession, $sElement, 'value', "fujimo")
    Sleep(500)

    ; Click search button
    Local $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='btnK']")
    _WD_ElementAction($sSession, $sButton, 'click')
    _WD_LoadWait($sSession, 2000)
EndFunc

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

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

Here is the error code it generates:

_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WD_Startup: OS:    WIN_10 WIN32_NT 19041 
_WD_Startup: AutoIt:    3.3.14.5
_WD_Startup: WD.au3:    0.4.0.3 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    chromedriver.exe
_WD_Startup: Params:    --verbose --log-path="C:\Users\MyName\Desktop\AutoIt\chrome.log"
_WD_Startup: Port:  9515
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false, "args":["--user-data-dir=C:\\Users\\MyName\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Default"]}}}}
__WD_Post: StatusCode=200; ResponseText={"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"90.0....
_WD_CreateSession: {"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"90.0.4430.93","chrome":{"chromedriverVersion":"90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429})","userDataDir":"C:\\Users\\MyName\\AppData\\Local\\Google\\Chrome\\User Data\\"},"goog:chromeOptions":{"debuggerAddress":"localhost:xxxxx"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"windows","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:largeBlob":true,"webauthn:virtualAuthenticators":true},"sessionId":"504fc8f09589db84dacb59e926c89635"}}
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/504fc8f09589db84dacb59e926c89635/url; $sData={"url":"http://google.com"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_Navigate: {"value":null}
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/504fc8f09589db84dacb59e926c89635/element; $sData={"using":"xpath","value":"//input[@name='q']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"e138d8b0-23b3-4bfd-ad4a-a7030fdb279f"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"e138d8b0-23b3-4bfd-ad4a-a7030fdb279f"}}
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/504fc8f09589db84dacb59e926c89635/element/e138d8b0-23b3-4bfd-ad4a-a7030fdb279f/value; $sData={"id":"e138d8b0-23b3-4bfd-ad4a-a7030fdb279f", "text":"fujimo"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_ElementAction: {"value":null}...
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/504fc8f09589db84dacb59e926c89635/element; $sData={"using":"xpath","value":"//input[@name='btnK']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"c176710a-81f6-49d6-ae23-a88a8530f6e5"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"c176710a-81f6-49d6-ae23-a88a8530f6e5"}}
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/504fc8f09589db84dacb59e926c89635/element/c176710a-81f6-49d6-ae23-a88a8530f6e5/click; $sData={"id":"c176710a-81f6-49d6-ae23-a88a8530f6e5"}
__WD_Post: StatusCode=200; ResponseText={"value":null}...
_WD_ElementAction: {"value":null}...
__WD_Post: URL=HTTP://xxx.x.x.x:xxx/session/504fc8f09589db84dacb59e926c89635/execute/sync; $sData={"script":"return document.readyState", "args":[]}
__WD_Post: StatusCode=200; ResponseText={"value":"complete"}...
_WD_ExecuteScript: {"value":"complete"}...
__WD_Delete: URL=HTTP://xxx.x.x.x:xxx/session/504fc8f09589db84dacb59e926c89635
__WD_Delete: StatusCode=200; ResponseText={"value":null}...
_WD_DeleteSession: {"value":null}
+>16:31:52 AutoIt3.exe ended.rc:0
+>16:31:52 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 32.04

If I may humbly request that in the next version of the UDF, you could alphabetize the function definitions. Without formal documentation, finding the function definitions quickly to read the headers and source is much easier if they are in alphabetical order.

Finally, thank you for the tremendous amount of work that has gone into the UDF and this forum.

Edited by CodeWriter
Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 07/29/2022
  • 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...