Jump to content

Recommended Posts

Posted

@samibb That's nice. Did you have a question? FWIW --

6 minutes ago, samibb said:

_WD_Startup: WinHTTP:    1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)

This information is here to assist you, so you should do as it says. 😉

8 minutes ago, samibb said:

_WD_Action ==> Invalid data type [3] : (Actions|Back|Forward|Refresh|Title|Url) $sCommand=>default

This is coming from somewhere else in your code that you didn't post.

Posted (edited)

@Danp2

google chrome version 129 ......71 64bit

i have got $sCapabilities No.

but i could not find the element.

how to solve ?

Thanks 

 

Func SetupChrome();$bHeadless)
    $bHeadless = True
    _WD_Option('Driver', 'chromedriver.exe')
    Local $iPort = _WD_GetFreePort(5555, 5600)
    
    If @error Then Return SetError(@error, @extended, 0)

    _WD_Option('Port', $iPort)
    _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"')

'i was using"
    ; $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"debuggerAddress": "localhost:9222"}}}}'


     Local $sCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "excludeSwitches": [ "enable-automation"]}}}}'
    _WD_CapabilitiesStartup()
    _WD_CapabilitiesAdd('alwaysMatch', 'chrome')
    _WD_CapabilitiesAdd('w3c', True)
    _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')

    If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless')
    _WD_CapabilitiesDump(@ScriptLineNumber) ; dump current Capabilities setting to console - only for testing in this demo
    Local     $sCapabilities = _WD_CapabilitiesGet()
    
    Return $sCapabilities
EndFunc   ;==>SetupChrome


"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Users\HP\Desktop\AutoIt\chrom_driver.au3"    
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe
_WD_GetFreePort ==> Success [0 / 5555] : Parameters:   MinPort=5555   MaxPort=5600
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=5555
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log"
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: chrome
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesDump: JSON structure starts below: 174
{
    "capabilities":{
        "alwaysMatch":{
            "goog:chromeOptions":{
                "w3c":true,
                "excludeSwitches":[
                    "enable-automation"
                ],
                "args":[
                    "--headless"
                ]
            }
        }
    }
}
_WD_CapabilitiesDump: JSON structure ends above.
_WD_GetFreePort ==> Success [0 / 5555] : Parameters:   MinPort=5555   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_11 X64 22631 
_WD_Startup: AutoIt:    3.3.16.1
_WD_Startup: Webdriver UDF: 1.4.0 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)
_WD_Startup: Driver:    chromedriver.exe (64 Bit)
_WD_Startup: Params:    --port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log"
_WD_Startup: Port:  5555
_WD_Startup: Command:   "chromedriver.exe" --port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log" 
_WD_Startup ==> Success [0]
$sCapabilities : {
    "capabilities":{
        "alwaysMatch":{
            "goog:chromeOptions":{
                "w3c":true,
                "excludeSwitches":[
                    "enable-automation"
                ],
                "args":[
                    "--headless"
                ]
            }
        }
    }
}
__WD_Post ==> Success [0] : HTTP status = 200
_WD_CreateSession ==> Success [0] : 5743c66263da0eb9945afd29d060d2ff
$sSession : 5743c66263da0eb9945afd29d060d2ff
***********************************************************************************************************
Starting ChromeDriver 129.0.6668.70 (df87d5cf12b1397be7495a04cab2db6239b227a8-refs/branch-heads/6668@{#1420}) on port 5555
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully on port 5555.

DevTools listening on ws://127.0.0.1:61114/devtools/browser/be3b99c3-f5c0-4d0f-93f2-ebbc66c8b025
Created TensorFlow Lite XNNPACK delegate for CPU.

 

Edited by samibb
add
Posted

No reason to SHOUT. There could be several potential causes --

  • Chrome -- You could test with a different browser
  • Website -- The format could have changed making your script outdated

If you want further assistance with this, then you should post a short "reproducer" script that we can run to observe the issue. If you are unable to do this, then the only other advice that I have is to stop running in a headless browser so that you can actually see what is occurring.

Posted
On 10/6/2024 at 2:06 PM, Danp2 said:

No reason to SHOUT. There could be several potential causes --

  • Chrome -- You could test with a different browser
  • Website -- The format could have changed making your script outdated

If you want further assistance with this, then you should post a short "reproducer" script that we can run to observe the issue. If you are unable to do this, then the only other advice that I have is to stop running in a headless browser so that you can actually see what is occurring.

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <winAPIFiles.au3>
#include <WinAPIvkeysConstants.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>
#include <IE.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <Clipboard.au3>
#include <Excel.au3>
#include <File.au3>
#include <ColorConstants.au3>
#include <AutoItConstants.au3>
#include <WinAPIEx.au3>
#include <Constants.au3>
#include <SendMessage.au3>
#include <WinAPI.au3>
#include "wd_helper.au3"
#include "wd_capabilities.au3"
Func Start_Chrome()
ProcessClose("chromedriver.exe")
_WD_Shutdown()
;$_WD_DEBUG = $_WD_DEBUG_None
 SetupChrome()
MsgBox(0,'sCapabilities',$sCapabilities)
 Local $SatrtUp = _WD_Startup()   ; OK  
ConsoleWrite('$atrtUp PID: ' & $atrtUp &@CRLF)   
MsgBox(0,'$atrtUp PID: ',$SatrtUp )
;ConsoleWrite('$sCapabilities : ' & $sCapabilities &@CRLF)
;connectWeb_Chrome()
;Global $attach = _WD_Attach($hWnd,"Altéa Reservation Desktop",Default)
;MsgBox(1,'$attach' ,$sCapabilities)
 
 $sSession = _WD_CreateSession($sCapabilities)
 ConsoleWrite('$sSession : '& $sSession &@CRLF)
 MsgBox(0,'$sSession',$sSession)
 
EndFunc
;************************************************************************
Func SetupChrome($bHeadless = False, $bUseLocalhostDebugging = True)
    ; Set up the ChromeDriver and options
    _WD_Option('Driver', 'chromedriver.exe')
    
    ; Get a free port between 5555 and 5600
    Local $iPort = _WD_GetFreePort(5555, 5600)
    
    ; Handle errors
    If @error Then Return SetError(@error, @extended, 0)

    ; Set ChromeDriver port and parameters
    _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"')

    ; Initialize WebDriver capabilities
    _WD_CapabilitiesStartup()

    ; Chrome-specific capabilities
   ; If $bUseLocalhostDebugging Then
        ; Attach to existing Chrome instance using debuggerAddress (localhost:9222 or another free port)
    ;    _WD_CapabilitiesAdd('goog:chromeOptions', '{"debuggerAddress": "localhost:' & $iPort & '"}')
   ; Else
        ; Regular Chrome startup
        ; Regular Chrome startup
        _WD_CapabilitiesAdd('alwaysMatch', 'chrome')
        _WD_CapabilitiesAdd('w3c', True) ; Enable W3C protocol
        ;_WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') ; Remove automation flag
        _WD_CapabilitiesAdd('debuggerAddress', 'localhost:'&$iPort)

        ; Add headless argument if needed
    ;    If $bHeadless Then
          ;  _WD_CapabilitiesAdd('goog:chromeOptions.args', '--headless')
    ;    EndIf
   ; EndIf

    ; Print out the capabilities to the console (for debugging)
    _WD_CapabilitiesDump(@ScriptLineNumber)

    ; Get the capabilities as a JSON string to pass to WebDriver
    $sCapabilities = _WD_CapabilitiesGet()
;MsgBox(0,555,$sCapabilities)
    ; Return the capabilities to use for the WebDriver session
    Return $sCapabilities
EndFunc   ;==>SetupChrome
;****************************************************************************

I NEVER SHOUT, Especially TO you

AS YOU SEE IN CONSOL RESULT:

"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "C:\Users\HP\Desktop\AutoIt\chrom_driver.au3"    
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe
_WD_GetFreePort ==> Success [0 / 5555] : Parameters:   MinPort=5555   MaxPort=5600
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log"
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: chrome
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesDump: JSON structure starts below: 217
{
    "capabilities":{
        "alwaysMatch":{
            "goog:chromeOptions":{
                "w3c":true,
                "debuggerAddress":"localhost:5555"
            }
        }
    }
}
_WD_CapabilitiesDump: JSON structure ends above.
_WD_GetFreePort ==> Success [0 / 0] : Parameters:   MinPort=0   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_11 X64 22631 
_WD_Startup: AutoIt:    3.3.16.1
_WD_Startup: Webdriver UDF:    1.4.0 (Up to date)
_WD_Startup: WinHTTP:    1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)
_WD_Startup: Driver:    chromedriver.exe (64 Bit)
_WD_Startup: Params:    --port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log"
_WD_Startup: Port:    0
_WD_Startup: Command:    "chromedriver.exe" --port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log" 
_WD_Startup ==> Success [0]
$atrtUp PID: 12344
__WD_Post ==> Send / Recv error [6] : HTTP status = 0
_WD_CreateSession ==> Webdriver Exception [10]
$sSession :  

  • Developers
Posted
2 minutes ago, samibb said:

I NEVER SHOUT, Especially TO you

AS YOU SEE IN CONSOL RESULT:

YES YOU DO as you are typing in capital letters, which is considered shouting!

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.
  :)

Posted
3 hours ago, Danp2 said:

@samibb 

  • You haven't fixed the issue related to WinHTTP that I pointed out to your here
  • Previously, your call to _WD_CreateSession was successful. Now it is failing, which is a completely different issue. It seems that you are missing this line in SetupChrome --
     
    _WD_Option('Port', $iPort)

:bye:

i did:

i have run with and with out  --remote-debugging-port=9222 in google chrome icon

what i missed ?

Func SetupChrome($bHeadless = True, $bUseLocalhostDebugging = False)
    ; Set up the ChromeDriver and options
     ;--remote-debugging-port=9222
    _WD_Option('Driver', 'chromedriver.exe')
    
    ; Get a free port between 5555 and 5600
   Local $iPort = _WD_GetFreePort(5555, 5600)
    _WD_Option('Port', $iPort)
    
    ; Handle errors
    If @error Then Return SetError(@error, @extended, 0)

    ; Set ChromeDriver port and parameters
    _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & @ScriptDir & '\chrome.log"')

    ; Initialize WebDriver capabilities
    _WD_CapabilitiesStartup()

    ; Chrome-specific capabilities
   ; If $bUseLocalhostDebugging Then
        ; Attach to existing Chrome instance using debuggerAddress (localhost:9222 or another free port)
    ;    _WD_CapabilitiesAdd('goog:chromeOptions', '{"debuggerAddress": "localhost:' & $iPort & '"}')
   ; Else
        ; Regular Chrome startup
        ; Regular Chrome startup
        _WD_CapabilitiesAdd('alwaysMatch', 'chrome')
        ;_WD_CapabilitiesAdd('w3c', True) ; Enable W3C protocol
       _WD_CapabilitiesAdd('excludeSwitches', 'enable-automation') ; Remove automation flag
       _WD_CapabilitiesAdd('args', '--headless')
        _WD_CapabilitiesAdd('debuggerAddress', 'localhost:'&$iPort)
    ;If $bHeadless Then _WD_CapabilitiesAdd('args', '--headless')
        ; Add headless argument if needed
    ;    If $bHeadless Then
          ;  _WD_CapabilitiesAdd('goog:chromeOptions.args', '--headless')
    ;    EndIf
   ; EndIf

    ; Print out the capabilities to the console (for debugging)
    _WD_CapabilitiesDump(@ScriptLineNumber)

    ; Get the capabilities as a JSON string to pass to WebDriver
    $sCapabilities = _WD_CapabilitiesGet()
;MsgBox(0,555,$sCapabilities)
    ; Return the capabilities to use for the WebDriver session
    Return $sCapabilities
EndFunc   ;==>SetupChrome
;***********************************************************************
WD_CapabilitiesDump: JSON structure ends above.
_WD_GetFreePort ==> Success [0 / 5555] : Parameters:   MinPort=5555   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_11 X64 22631 
_WD_Startup: AutoIt:    3.3.16.1
_WD_Startup: Webdriver UDF: 1.4.0 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.1 (Download latest source at <https://raw.githubusercontent.com/dragana-r/autoit-winhttp/master/WinHttp.au3>)
_WD_Startup: Driver:    chromedriver.exe (64 Bit)
_WD_Startup: Params:    --port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log"
_WD_Startup: Port:  5555
_WD_Startup: Command:   "chromedriver.exe" --port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log" 
_WD_Startup ==> Success [0]
$atrtUp PID: 2332
__WD_Post ==> Invalid argument [5] : HTTP status = 400
_WD_CreateSession ==> Webdriver Exception [10]
$sSession :

 

  • 2 weeks later...
Posted

Dear @Danp2

Relay i don not know how to open separate thread, and i do not want make any mistake . so please i need your help.

i have solve a part of the case I've got the session id , but i could not connect to web page. I've update WinHTTP. 

the problem is could not  add: _WD_CapabilitiesAdd("debuggerAddress","localhost:9222"). 

Thanks

Func SetupChrome($bHeadless = False, $bUseLocalhostDebugging = False)
    
    ; Set up the ChromeDriver and options
    _WD_Option('Driver', 'chromedriver.exe')
    
    ; Get a free port between 5555 and 5600
    Local $iPort = _WD_GetFreePort(5555, 5600)
    
    ; Handle errors
    If @error Then Return SetError(@error, @extended, 0)

    ; Set ChromeDriver port and parameters
   _WD_Option('Port', $iPort)
    _WD_Option('DriverParams', '--port=' & $iPort & ' --verbose --log-path="' & "C:\Users\HP\Desktop\AutoIt" & '\chrome.log')

    ; Initialize WebDriver capabilities
    _WD_CapabilitiesStartup()
;" --remote-debugging-port=9222
    
        ; Regular Chrome startup
         _WD_CapabilitiesAdd('alwaysMatch', 'chrome')
       _WD_CapabilitiesAdd('w3c', True) ; Enable W3C protocol
       _WD_CapabilitiesAdd('args', '--headless')
       ;****************************************************************************
       ;_WD_CapabilitiesAdd("debuggerAddress","localhost:9222")   ??????????? not wogrkin
       ;*****************************************************************************
       ; Print out the capabilities to the console (for debugging)
    _WD_CapabilitiesDump(@ScriptLineNumber)

    ; Get the capabilities as a JSON string to pass to WebDriver
    $sCapabilities = _WD_CapabilitiesGet()

    ; Return the capabilities to use for the WebDriver session
    Return $sCapabilities
EndFunc   ;==>SetupChrome
;**************************************************************************************************
_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=chromedriver.exe
_WD_GetFreePort ==> Success [0 / 5555] : Parameters:   MinPort=5555   MaxPort=5600
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=5555
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log
_WD_CapabilitiesAdd ==> Browser or feature not supported [21] : Not supported KEY parameter ( must be defined in $_WD_KEYS__*** ).      $key = goog:chromeOptions     $value1 = debuggerAddress     $value2 = 
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch]  with specified browser: chrome
_WD_CapabilitiesDump: JSON structure starts below: 363
{
    "capabilities":{}
}
_WD_CapabilitiesDump: JSON structure ends above.
_WD_GetFreePort ==> Success [0 / 5555] : Parameters:   MinPort=5555   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_11 X64 22631 
_WD_Startup: AutoIt:    3.3.16.1
_WD_Startup: Webdriver UDF: 1.4.0 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    chromedriver.exe (64 Bit)
_WD_Startup: Params:    --port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log
_WD_Startup: Port:  5555
_WD_Startup: Command:   "chromedriver.exe" --port=5555 --verbose --log-path="C:\Users\HP\Desktop\AutoIt\chrome.log 
_WD_Startup ==> Success [0]
__WD_Post ==> Success [0] : HTTP status = 200
_WD_CreateSession ==> Success [0] : 197bbede6f948a50f6856eac905bdb1f
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Action ==> Success [0] : Parameters:   Command=url   Option=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=handles   Option=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=window   Option=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=Switch   Option={"handle":"5EDB7BC890065422E77FEC49DA5E6217"}
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Action ==> Success [0] : Parameters:   Command=title   Option=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=Switch   Option={"handle":"5EDB7BC890065422E77FEC49DA5E6217"}
_WD_Attach ==> No match [8] : Parameters:    Search=Alt顠Reservation Desktop    Mode=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=HANDLES   Option=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=handles   Option=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=window   Option=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=Switch   Option={"handle":"5EDB7BC890065422E77FEC49DA5E6217"}
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Action ==> Success [0] : Parameters:   Command=title   Option=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=Switch   Option={"handle":"5EDB7BC890065422E77FEC49DA5E6217"}
_WD_Attach ==> No match [8] : Parameters:    Search=Alt顠Reservation Desktop    Mode=Default
__WD_Get ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=HANDLES   Option=Default
__WD_Post ==> Success [0] : HTTP status = 200
_WD_Window ==> Success [0] : Parameters:   Command=MAXIMIZE   Option=Alt顠Reservation Desktop
__WD_Post ==> No match [8] : HTTP status = 404
_WD_FindElement ==> No match [8] : Parameters:   Strategy=xpath   Selector=/html/body/div[1]/div[5]/div/div/div/div[3]/div[3]/div/div[2]/div/div[3]/div/div[4]/div[2]/div/div/span/span/div/div[1]/div/div[2]/div/div/div[2]/span[2]/div/textarea   StartNodeID=Default   Multiple=Default   ShadowRoot=Default
__WD_Post ==> No match [8] : HTTP status = 404

  

Posted
2 hours ago, samibb said:

i don not know how to open separate thread, and i do not want make any mistake

  1. navigate to https://www.autoitscript.com/forum/forum/2-autoit-general-help-and-support/
  2. press button "Start new topic"
  3. add your title and description of your question(s) / topic

Then @samibb you probably will get helped.

Best regards
Sven

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

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...