Jump to content

WebDriver UDF (W3C compliant version) - 2024/02/19


Danp2
 Share

Recommended Posts

@yeison1412

  1. This is an English speaking forum. So please either write in English, use Google translate or post on the Spanish forum (I assume there is one somewhere 😀)
  2. See here for the proper way to post code on the forum.
  3. Please post the complete results from the Scite output panel (don't take a screen grab; copy and paste the texting using #2 above)
Link to comment
Share on other sites

This is a code that I found on the internet to start chrome control but it sends me a set of errors. Something is missing in the includes and I also have the chrome driver according to the version of my chrome.

But doesnt work, only show the next errors

i appreciate your answers

#include "wd_core.au3"
#include "wd_helper.au3"
Local $sDesiredCapabilities, $sSession
SetupChrome()

_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://es-la.facebook.com")
_ChromeSetInputValueById($sSession,'email','abc')
_ChromeSetInputValueById($sSession,'pass','xyz')
_WD_Shutdown()

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

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":[' & """start-maximized""," & " ""disable-infobars""" & "" & '] }}}}'
EndFunc   ;==>SetupChrome
Func _ChromeSetInputValueById($sSession,$Id,$Value)
 $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@id='"&$Id&"']")
 _WD_ElementAction($sSession,$sButton,'value', $Value)
EndFunc



>Running AU3Check (3.3.14.5)  from:C:\Users\user pc\Desktop\AutoIt4  input:E:\programas\Multimedia\documentos\autoit\pizarra chrome.au3
+>07:23:51 AU3Check ended.rc:0
>Running:(3.3.14.5):C:\Users\user pc\Desktop\AutoIt4\autoit3.exe "E:\programas\Multimedia\documentos\autoit\pizarra chrome.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
_WD_IsLatestRelease: True
_WD_IsLatestRelease ==> Success
_WDStartup: OS: WIN_81 WIN32_NT 9600 
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.3.0.1 (Up to date)
_WDStartup: WinHTTP:    1.6.4.1
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --log-path="E:\programas\Multimedia\documentos\autoit\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars"] }}}}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"invalid argument: unrecognized capability: chromeOpt...
_WD_CreateSession: {"value":{"error":"invalid argument","message":"invalid argument: unrecognized capability: chromeOptions","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C19563+2725219]\n\tOrdinal0 [0x00B18551+1672529]\n\tOrdinal0 [0x00A00359+525145]\n\tOrdinal0 [0x0098623C+25148]\n\tOrdinal0 [0x009ABE2A+179754]\n\tOrdinal0 [0x009ABBC7+179143]\n\tOrdinal0 [0x009ACAD0+182992]\n\tOrdinal0 [0x009ACA3D+182845]\n\tOrdinal0 [0x009AA94B+174411]\n\tOrdinal0 [0x00992528+75048]\n\tOrdinal0 [0x009935A0+79264]\n\tOrdinal0 [0x00993539+79161]\n\tOrdinal0 [0x00B2D607+1758727]\n\tGetHandleVerifier [0x00D36546+1050150]\n\tGetHandleVerifier [0x00D36291+1049457]\n\tGetHandleVerifier [0x00D410D7+1094071]\n\tGetHandleVerifier [0x00D36B46+1051686]\n\tOrdinal0 [0x00B25B06+1727238]\n\tOrdinal0 [0x00B2EB7B+1764219]\n\tOrdinal0 [0x00B2ECE3+1764579]\n\tOrdinal0 [0x00B44C05+1854469]\n\tBaseThreadInitThunk [0x74E47C04+36]\n\tRtlInitializeExceptionChain [0x7725B90F+143]\n\tRtlInitializeExceptionChain [0x7725B8DA+90]\n"}}
_WD_CreateSession ==> Webdriver Exception: invalid argument: unrecognized capability: chromeOptions
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"https://es-la.facebook.com"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOr...
_WD_Navigate: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C19563+2725219]\n\tOrdinal0 [0x00B18551+1672529]\n\tOrdinal0 [0x00A00202+524802]\n\tOrdinal0 [0x00992099+73881]\n\tOrdinal0 [0x009AAA17+174615]\n\tOrdinal0 [0x009A949A+169114]\n\tOrdinal0 [0x009A9074+168052]\n\tOrdinal0 [0x0098235E+9054]\n\tOrdinal0 [0x009827C6+10182]\n\tOrdinal0 [0x00982E50+11856]\n\tOrdinal0 [0x00B2D607+1758727]\n\tGetHandleVerifier [0x00D36546+1050150]\n\tGetHandleVerifier [0x00D36291+1049457]\n\tGetHandleVerifier [0x00D410D7+1094071]\n\tGetHandleVerifier [0x00D36B46+1051686]\n\tOrdinal0 [0x00B25B06+1727238]\n\tOrdinal0 [0x00982213+8723]\n\tOrdinal0 [0x00981F20+7968]\n\tGetHandleVerifier [0x00F0DC8C+2981228]\n\tBaseThreadInitThunk [0x74E47C04+36]\n\tRtlInitializeExceptionChain [0x7725B90F+143]\n\tRtlInitializeExceptionChain [0x7725B8DA+90]\n"}}
_WD_Navigate ==> Invalid session ID: HTTP status = 404
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//input[@id='email']"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOr...
_WD_FindElement: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C19563+2725219]\n\tOrdinal0 [0x00B18551+1672529]\n\tOrdinal0 [0x00A00202+524802]\n\tOrdinal0 [0x00992099+73881]\n\tOrdinal0 [0x009AAA17+174615]\n\tOrdinal0 [0x009A949A+169114]\n\tOrdinal0 [0x009A9074+168052]\n\tOrdinal0 [0x0098235E+9054]\n\tOrdinal0 [0x009827C6+10182]\n\tOrdinal0 [0x00982E50+11856]\n\tOrdinal0 [0x00B2D607+1758727]\n\tGetHandleVerifier [0x00D36546+1050150]\n\tGetHandleVerifier [0x00D36291+1049457]\n\tGetHandleVerifier [0x00D410D7+1094071]\n\tGetHandleVerifier [0x00D36B46+1051686]\n\tOrdinal0 [0x00B25B06+1727238]\n\tOrdinal0 [0x00982213+8723]\n\tOrdinal0 [0x00981F20+7968]\n\tGetHandleVerifier [0x00F0DC8C+2981228]\n\tBaseThreadInitThunk [0x74E47C04+36]\n\tRtlInitializeExceptionChain [0x7725B90F+143]\n\tRtlInitializeExceptionChain [0x7725B8DA+90]\n"}}
_WD_FindElement ==> Invalid session ID: HTTP status = 404
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element//value; $sData={"id":"", "text":"abc"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOr...
_WD_ElementAction: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOr...
_WD_ElementAction ==> Invalid session ID: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C19563+2725219]\n\tOrdinal0 [0x00B18551+1672529]\n\tOrdinal0 [0x00A00202+524802]\n\tOrdinal0 [0x00992099+73881]\n\tOrdinal0 [0x009AAA17+174615]\n\tOrdinal0 [0x009A949A+169114]\n\tOrdinal0 [0x009A9074+168052]\n\tOrdinal0 [0x0098235E+9054]\n\tOrdinal0 [0x009827C6+10182]\n\tOrdinal0 [0x00982E50+11856]\n\tOrdinal0 [0x00B2D607+1758727]\n\tGetHandleVerifier [0x00D36546+1050150]\n\tGetHandleVerifier [0x00D36291+1049457]\n\tGetHandleVerifier [0x00D410D7+1094071]\n\tGetHandleVerifier [0x00D36B46+1051686]\n\tOrdinal0 [0x00B25B06+1727238]\n\tOrdinal0 [0x00982213+8723]\n\tOrdinal0 [0x00981F20+7968]\n\tGetHandleVerifier [0x00F0DC8C+2981228]\n\tBaseThreadInitThunk [0x74E47C04+36]\n\tRtlInitializeExceptionChain [0x7725B90F+143]\n\tRtlInitializeExceptionChain [0x7725B8DA+90]\n"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//input[@id='pass']"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOr...
_WD_FindElement: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C19563+2725219]\n\tOrdinal0 [0x00B18551+1672529]\n\tOrdinal0 [0x00A00202+524802]\n\tOrdinal0 [0x00992099+73881]\n\tOrdinal0 [0x009AAA17+174615]\n\tOrdinal0 [0x009A949A+169114]\n\tOrdinal0 [0x009A9074+168052]\n\tOrdinal0 [0x0098235E+9054]\n\tOrdinal0 [0x009827C6+10182]\n\tOrdinal0 [0x00982E50+11856]\n\tOrdinal0 [0x00B2D607+1758727]\n\tGetHandleVerifier [0x00D36546+1050150]\n\tGetHandleVerifier [0x00D36291+1049457]\n\tGetHandleVerifier [0x00D410D7+1094071]\n\tGetHandleVerifier [0x00D36B46+1051686]\n\tOrdinal0 [0x00B25B06+1727238]\n\tOrdinal0 [0x00982213+8723]\n\tOrdinal0 [0x00981F20+7968]\n\tGetHandleVerifier [0x00F0DC8C+2981228]\n\tBaseThreadInitThunk [0x74E47C04+36]\n\tRtlInitializeExceptionChain [0x7725B90F+143]\n\tRtlInitializeExceptionChain [0x7725B8DA+90]\n"}}
_WD_FindElement ==> Invalid session ID: HTTP status = 404
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element//value; $sData={"id":"", "text":"xyz"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOr...
_WD_ElementAction: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOr...
_WD_ElementAction ==> Invalid session ID: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00C19563+2725219]\n\tOrdinal0 [0x00B18551+1672529]\n\tOrdinal0 [0x00A00202+524802]\n\tOrdinal0 [0x00992099+73881]\n\tOrdinal0 [0x009AAA17+174615]\n\tOrdinal0 [0x009A949A+169114]\n\tOrdinal0 [0x009A9074+168052]\n\tOrdinal0 [0x0098235E+9054]\n\tOrdinal0 [0x009827C6+10182]\n\tOrdinal0 [0x00982E50+11856]\n\tOrdinal0 [0x00B2D607+1758727]\n\tGetHandleVerifier [0x00D36546+1050150]\n\tGetHandleVerifier [0x00D36291+1049457]\n\tGetHandleVerifier [0x00D410D7+1094071]\n\tGetHandleVerifier [0x00D36B46+1051686]\n\tOrdinal0 [0x00B25B06+1727238]\n\tOrdinal0 [0x00982213+8723]\n\tOrdinal0 [0x00981F20+7968]\n\tGetHandleVerifier [0x00F0DC8C+2981228]\n\tBaseThreadInitThunk [0x74E47C04+36]\n\tRtlInitializeExceptionChain [0x7725B90F+143]\n\tRtlInitializeExceptionChain [0x7725B8DA+90]\n"}}
+>07:23:54 AutoIt3.exe ended.rc:0
+>07:23:54 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 6.106

 

Link to comment
Share on other sites

20 minutes ago, yeison1412 said:

_WD_CreateSession ==> Webdriver Exception: invalid argument: unrecognized capability: chromeOptions

Please get accustomed to reviewing this output log for error messages. In this case, it's telling you that "chromeOptions" isn't recognized. This is because they changed it to "goog:ChromeOptions". Try it with this line in place of your other one  --

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

 

Link to comment
Share on other sites

@Danp2, I've been using this code to check if there are updates to any component of your WebDriver UDF including the UDF itself. I thought this code could help someone who just starts using WebDriver to get all the components without a hassle.. This code does not use any WebDriver UDF functions because it was assumed that the user may not have the WebDriver UDF installed. As you will see, I could not figure out how to determine if there was an update to Json.au3. My code just downloads it if it does not exist in the script driectory. This code assumes the use of chromedriver. Other browser users will have to change the code a liitle bit to update their own webdrivers. I know my code is very much amateurish. If you see any usage of this code, I would hope you could throw in some expert's touches.

; WebDriverUpdater.au3
#include <Inet.au3>
#include <String.au3>

If Ping("www.google.com") = 0 Then
    Exit
EndIf

Local $sDriverPath, $hFile, $sMsg, $sChromePath, $sChromeVersion, $sChromeVersionShort, $iPID, $sOutput, $aResult
Local $sCurrentVersion, $sLatestVersion, $iSize, $sZipFile, $oShell, $FilesInZip, $hTime, $sGithub, $sUDF, $aLink, $sLink

$sDriverPath = @ScriptDir & "\"
$hFile = FileOpen($sDriverPath & "\WebDriverUpdater.log", 1+128)
$sMsg = "Update details:"

$sChromePath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe", "")
If @error Then Exit MsgBox(0, "WebDriver Updater", "Please try after installation of Chrome browser!")

; Install/Update ChromeDriver.exe
$sChromeVersion = FileGetVersion($sChromePath)
$sChromeVersionShort = StringLeft($sChromeVersion, StringInStr($sChromeVersion, ".", 0, -1) -1)
$sMsg &= @CRLF & "Chrome Version" & Chr(9) & Chr(9) & $sChromeVersion

If FileExists($sDriverPath & "chromedriver.exe") Then
    $iPID = Run($sDriverPath & "chromedriver.exe --version", @ScriptDir, @SW_HIDE, $STDOUT_CHILD)
    ProcessWaitClose($iPID)
    $sOutput = StdoutRead($iPID)
    $aResult = _StringBetween($sOutput, "ChromeDriver ", " (")
    $sCurrentVersion = $aResult[0]
Else
    $sCurrentVersion = "None"
EndIf

$sLatestVersion = BinaryToString(InetRead("https://chromedriver.storage.googleapis.com/LATEST_RELEASE_" & $sChromeVersionShort), 4)

$iSize = 0
If $sCurrentVersion <> $sLatestVersion Then
    $sZipFile = $sDriverPath & "chromedriver_win32.zip"
    $iSize = InetGet("https://chromedriver.storage.googleapis.com/" & $sLatestVersion & "/chromedriver_win32.zip", $sZipFile, $INET_FORCERELOAD, $INET_DOWNLOADWAIT)
    ;https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_win32.zip
    If $iSize > 1 Then
        ProcessClose("chromedriver.exe")
        $oShell = ObjCreate ("Shell.Application")
        $FilesInZip = $oShell.NameSpace($sZipFile).items
        $oShell.NameSpace($sDriverPath).CopyHere($FilesInZip, 20) ; 4 - Do not display a progress dialog box, 16 - Click "Yes to All" in any dialog box displayed
    EndIf
Else
    $iSize = 1
EndIf
If $iSize = 0 Then
    $sMsg &= @CRLF & "ChromeDriver.exe" & Chr(9) & Chr(9) & "Update failed"
ElseIf $iSize = 1 Then
    $sMsg &= @CRLF & "ChromeDriver.exe" & Chr(9) & Chr(9) & "Up to date"
Else
    FileWriteLine($hFile, _NowCalc() & " - ChromeDriver.exe" & Chr(9) & "(" & $sLatestVersion & ")")
    $sMsg &= @CRLF & "ChromeDriver.exe" & Chr(9) & Chr(9) & "Updated" ; "(" & $sLatestVersion & ")"
EndIf

; Install/Update WebDriver UDF
$sGithub = BinaryToString(InetRead("https://github.com/Danp2/WebDriver/releases/latest"), 4)
$hTime = TimerInit()
While 1
    If StringInStr($sGithub, '<a href="/Danp2/WebDriver/releases/tag/') Then
        ExitLoop
    EndIf
    Sleep(50)
    If TimerDiff($hTime) > 5000 Then
        $sGithub = ""
        ExitLoop
    EndIf
WEnd

$iSize = 0
If $sGithub <> "" Then
    $aResult = StringRegExp($sGithub, '<a href="/Danp2/WebDriver/releases/tag/(.*)">', 1)
    $sLatestVersion = $aResult[0]
    If FileExists($sDriverPath & "wd_core.au3") Then
        $sUDF = FileRead($sDriverPath & "wd_core.au3")
        $aResult = StringRegExp($sUDF, 'WDVERSION = \"\d*\.\d*\.\d*\.\d*', 1)
        $sCurrentVersion = StringMid($aResult[0], 14)
    Else
        $sCurrentVersion = "None"
    EndIf
    If $sLatestVersion <> $sCurrentVersion Then
        $sZipFile = $sDriverPath & "WebDriver-" & $sLatestVersion & ".zip"
        $iSize = InetGet("https://github.com/Danp2/WebDriver/archive/" & $sLatestVersion & ".zip", $sZipFile, $INET_FORCERELOAD, $INET_DOWNLOADWAIT)
        If $iSize > 1 Then
            $oShell = ObjCreate ("Shell.Application")
            $FilesInZip = $oShell.NameSpace($sZipFile).items
            $oShell.NameSpace($sDriverPath).CopyHere($FilesInZip, 20)
            FileCopy($sDriverPath & "WebDriver-" & $sLatestVersion & "\*.*", $sDriverPath & "*.*", 1)
            DirRemove($sDriverPath & "WebDriver-" & $sLatestVersion, 1)
        EndIf
    Else
        $iSize = 1
    EndIf
EndIf
If $iSize = 0 Then
    $sMsg &= @CRLF & "WebDriver UDF" & Chr(9) & Chr(9) & "Update failed"
ElseIf $iSize = 1 Then
    $sMsg &= @CRLF & "WebDriver UDF" & Chr(9) & Chr(9) & "Up to date"
Else
    FileWriteLine($hFile, _NowCalc() & " - WebDriver UDF" & Chr(9) & Chr(9) & "(" & $sLatestVersion & ")")
    $sMsg &= @CRLF & "WebDriver UDF" & Chr(9) & Chr(9) & "Updated" ; "(" & $sLatestVersion & ")"
EndIf

; Install/Update WinHttp.au3
$sGithub = BinaryToString(InetRead("https://github.com/dragana-r/autoit-winhttp/releases"), 4)
$hTime = TimerInit()
While 1
    If StringInStr($sGithub, '<div class="release-entry">') Then
        ExitLoop
    EndIf
    Sleep(50)
    If TimerDiff($hTime) > 5000 Then
        $sGithub = ""
        ExitLoop
    EndIf
WEnd

$iSize = 0
If $sGithub <> "" Then
    $aResult = StringRegExp($sGithub, "/\d*\.\d*\.\d*\.\d*", 1)
    $sLatestVersion = StringMid($aResult[0], 2)

    If FileExists($sDriverPath & "WinHTTP.au3") Then
        $sUDF = FileRead($sDriverPath & "WinHTTP.au3")
        $aResult = StringRegExp($sUDF, ": \d*\.\d*\.\d*\.\d*", 1)
        $sCurrentVersion = StringMid($aResult[0], 3)
    Else
        $sCurrentVersion = "None"
    EndIf
    If $sLatestVersion <> $sCurrentVersion Then
        $aLink = StringRegExp($sGithub, "href=.*\.zip", 1)
        $sLink = "https://github.com" & StringMid($aLink[0], 7)
        ;<a href="/dragana-r/autoit-winhttp/releases/download/1.6.4.1/1.6.4.1.zip"
        $sZipFile = $sDriverPath & "WinHttp-" & $sLatestVersion & ".zip"
        $iSize = InetGet($sLink, $sZipFile, $INET_FORCERELOAD, $INET_DOWNLOADWAIT)

        If $iSize > 1 Then
            $oShell = ObjCreate ("Shell.Application")
            $FilesInZip = $oShell.NameSpace($sZipFile).items
            $oShell.NameSpace($sDriverPath).CopyHere($FilesInZip, 20)
            FileCopy($sDriverPath & $sLatestVersion & "\*.*", $sDriverPath & "*.*", 1)
            DirRemove($sDriverPath & $sLatestVersion, 1)
        EndIf
    Else
        $iSize = 1
    EndIf
EndIf
If $iSize = 0 Then
    $sMsg &= @CRLF & "WinHttp.au3" & Chr(9) & Chr(9) & "Update failed"
ElseIf $iSize = 1 Then
    $sMsg &= @CRLF & "WinHttp.au3" & Chr(9) & Chr(9) & "Up to date"
Else
    FileWriteLine($hFile, _NowCalc() & " - WinHttp.au3" & Chr(9) & Chr(9) & "(" & $sLatestVersion & ")")
    $sMsg &= @CRLF & "WinHttp.au3" & Chr(9) & Chr(9) & "Updated" ; "(" & $sLatestVersion & ")"
EndIf

; Install/Update Json.au3 - I couldn't figure out how to determine the necessity of an update
$iSize = 0
If Not FileExists($sDriverPath & "Json.au3") Then
    $sZipFile = $sDriverPath & "Json.zip"
    $iSize = InetGet("https://www.autoitscript.com/forum/applications/core/interface/file/attachment.php?id=61831", $sZipFile)
    If $iSize > 0 Then
        $oShell = ObjCreate ("Shell.Application")
        $FilesInZip = $oShell.NameSpace($sZipFile).items
        $oShell.NameSpace($sDriverPath).CopyHere($FilesInZip, 20)
        FileWriteLine($hFile, _NowCalc() & " - Json.au3" & Chr(9) & Chr(9) & "Downloaded")
        $sMsg &= @CRLF & "WinHttp.au3" & Chr(9) & Chr(9) & "Downloaded"
    EndIf
Else
    $iSize = 1
EndIf
If $iSize = 0 Then
    $sMsg &= @CRLF & "Json.au3" & Chr(9) & Chr(9) & Chr(9) & "Update failed"
ElseIf $iSize = 1 Then
    $sMsg &= @CRLF & "Json.au3" & Chr(9) & Chr(9) & Chr(9) & "Existing"
Else
    $sMsg &= @CRLF & "Json.au3" & Chr(9) & Chr(9) & Chr(9) & "Downloaded"
EndIf

FileClose($hFile)

MsgBox(0, "WebDriver Updater", $sMsg, 120)

 

Edited by CYCho
Link to comment
Share on other sites

  • 3 weeks later...
15 hours ago, Danp2 said:

You should be able to accomplish this using _WD_ExecuteScript and the appropriate Javascript.

Yeah i already thought about this, but couldn't get it work. 

I took some try and error time and now i got it ! :)

Local $JScript = _
     'var elem = document.getElementsByClassName("navigation-bar-wrapper size-content");' & _
     'elem[0].remove();'
    _WD_ExecuteScript ( $sSession,$JScript )

Thanks anyway

why do i get garbage when i buy garbage bags? <_<

Link to comment
Share on other sites

v0.3.0.4 just released with the following changes --

    - Added: _WD_ExecuteCdpCommand (TheDcoder)
    - Changed (_WD_UpdateDriver): Add support for MSEdge (Chromium)
    - Changed (_WD_Shutdown): Allow shutdown of specific module by name or PID
    - Changed (_WD_Startup): Notify if WinHTTP UDF needs updated
    - Changed: Improved error handling / HTTP timeout detection

Link to comment
Share on other sites

  • 4 weeks later...

v0.3.0.5 just released with the following changes --

    - Added: _WD_GetTable (danylarson / water)
    - Fixed (_WD_FindElement): Enforce relative xpath when utilizing a starting element
    - Changed: Use InetRead instead of __WD_Get (_WD_IsLatestRelease & _WD_UpdateDriver)
    - Changed: Pass Content-Type header in HTTP request

Link to comment
Share on other sites

  • 3 weeks later...

So I've run into a road bump and I'm not sure if this UDF will be my answer to my problem. 

Problem -  I'm trying to find a solution that will automatically open firefox or chrome in a GUI. Not separately. Esri's workforce browser application isn't compatible using IE browser so I trying to find a solution that I can use to open a browser inside a GUI. Right now my script will open a browser and move it inside the GUI but I run into the issue of users closing the browser or messing the process up before it gets embedded. Looking forward to hearing back! Thanks!

Launch using shellexecute and embed in GUI

ShellExecute("firefox.exe", "https://egas.maps.arcgis.com/sharing/rest/oauth2/authorize?client_id=arcgisonline&display=default&response_type=token&state=%7B%22returnUrl%22%3A%22https%3A%2F%2Fegas.maps.arcgis.com%2Fapps%2Fwebappviewer%2Findex.html%3Fid%3De749ca4f26ff4b69b090ff548f042baf%22%2C%22useLandingPage%22%3Afalse%7D&expiration=20160&locale=en-us&redirect_uri=https%3A%2F%2Fegas.maps.arcgis.com%2Fhome%2Faccountswitcher-callback.html&force_login=false&hideCancel=true&showSignupOption=true&canHandleCrossOrgSignIn=true&signuptype=esri&redirectToUserOrgUrl=true")

Local $hPrivateIE = WinWait("[REGEXPTITLE:(?i)(.*'Mozilla Firefox')]", "", 3)
WinSetState($hPrivateIE, "", @SW_HIDE)
Local $oPrivateIE = _IEAttach($hPrivateIE, "hwnd")
$Nhandle = WinGetHandle("Mozilla Firefox")
_WinAPI_SetParent($Nhandle, $Gui)
$aPos = ControlGetPos($Gui, "",$hPrivateIE)
_WinAPI_MoveWindow($Nhandle, $aPos[0] - 400, $aPos[1] + 25, 10, 600, False)
_WinAPI_SetWindowLong($Nhandle, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
$aPos = ControlGetPos($Gui, "",$hPrivateIE)
WinMove($Nhandle, "", $aPos[0] + 5, $aPos[1] + 25, 10, 0)

Full Program

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <APISysConstants.au3>
#include <WinAPIEx.au3>
#include <IE.au3>

Opt("WinTitleMatchMode", 2) ; Alters the method that is used to match window titles during search operations.

; = GUICreate("TreeView Find Item", 800, 600, -1, -1, $WS_SIZEBOX)
$Gui = GUICreate("Project Tracking Beta v1", 800, 600, -1, -1, BitOR($WS_SIZEBOX  , $WS_CLIPCHILDREN,$WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX) , $WS_EX_COMPOSITED)
;GUICreate("Project Tracking Beta v1", 500, 316, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MAXIMIZEBOX, $WS_SIZEBOX))
GUISetState(@SW_SHOW, $Gui)



ShellExecute("firefox.exe", "https://egas.maps.arcgis.com/sharing/rest/oauth2/authorize?client_id=arcgisonline&display=default&response_type=token&state=%7B%22returnUrl%22%3A%22https%3A%2F%2Fegas.maps.arcgis.com%2Fapps%2Fwebappviewer%2Findex.html%3Fid%3De749ca4f26ff4b69b090ff548f042baf%22%2C%22useLandingPage%22%3Afalse%7D&expiration=20160&locale=en-us&redirect_uri=https%3A%2F%2Fegas.maps.arcgis.com%2Fhome%2Faccountswitcher-callback.html&force_login=false&hideCancel=true&showSignupOption=true&canHandleCrossOrgSignIn=true&signuptype=esri&redirectToUserOrgUrl=true")

Local $hPrivateIE = WinWait("[REGEXPTITLE:(?i)(.*'Mozilla Firefox')]", "", 3)
WinSetState($hPrivateIE, "", @SW_HIDE)
Local $oPrivateIE = _IEAttach($hPrivateIE, "hwnd")
$Nhandle = WinGetHandle("Mozilla Firefox")
_WinAPI_SetParent($Nhandle, $Gui)
$aPos = ControlGetPos($Gui, "",$hPrivateIE)
_WinAPI_MoveWindow($Nhandle, $aPos[0] - 400, $aPos[1] + 25, 10, 600, False)
_WinAPI_SetWindowLong($Nhandle, $GWL_STYLE, $WS_POPUP + $WS_VISIBLE)
$aPos = ControlGetPos($Gui, "",$hPrivateIE)
WinMove($Nhandle, "", $aPos[0] + 5, $aPos[1] + 25, 10, 0)

GUIRegisterMsg($WM_SIZE, "_WM_SIZE")

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd

Func _WM_SIZE($hWnd, $iMsg, $wParam, $lParam)

    ; Get label posiition and size and adjust child GUI to fit
  $aPos = ControlGetPos($Gui, "",$hPrivateIE)
  WinMove($Nhandle, "", $aPos[0] + 10, $aPos[1] + 25, $aPos[2] - 30, $aPos[3] - 30)

EndFunc

 

Link to comment
Share on other sites

  • Danp2 changed the title to WebDriver UDF (W3C compliant version) - 2024/02/19
  • Melba23 pinned this topic

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

×
×
  • Create New...