Jump to content

Recommended Posts

Posted

v0.3.1.0 has been released with the following updates --

  • Changed: Cleanup _WD_DownloadFile
    • Revise error list in header
    • Remove leftover $_WD_HTTPRESULT coding
    • Return $_WD_ERROR_NotFound instead of $_WD_ERROR_InvalidValue
  • Changed (_WD_WaitElement): Added optional parameter to return element instead of 0/1
  • Chore: Update function headers (Danp2 and seadoggie01)
  • Fix (_WD_Screenshot): Edit return value for Base64 screenshots (seadoggie01)
  • Fix (_WD_WaitElement): Clear variable holding element ID if visibility or enabled check fails
Posted (edited)

Hi @Danp2 !
Can you help me :(( . I have been using it for long time but today error i can't open chrome . i have reinstall chrome  and chrome driver same version ! but it not working . :(  
Thanks you 

#include "WinHttp.au3"
#include <FileConstants.au3>
#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <CoProc.au3>
Local $inhap,$nick,$pass,$IDTkqcLink,$N3getnuocvialencamp,$N3getnuocchinhcamp,$N3tuoi1,$N3tuoi2,$N3sothich,$N3idbaipost,$N3checktiennguong,$Thema,$Thengay,$TheCC,$Thebill = 10080
Local $sFill,$Cookie[10],$xsplitcookie
Local $aArray[0][3] ;= ["Item 0 - 0", "Item 0 - 1"]
Local $sDesiredCapabilities, $iIndex, $sSession
Local $nMsg, $lProcess = False

Setupopen()
   $sSession = _WD_CreateSession($sDesiredCapabilities)
   _WD_Navigate($sSession, "https://facebook.com")
   _WD_Action($sSession,"refresh")

Func SetupChrome()
_WD_Option('Driver', 'chromedriver81f.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
;$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true, "args":["--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Profile 1"]}}}}'
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}'
EndFunc
Func Setupopen()
   ; Set debug level
   $_WD_DEBUG = $_WD_DEBUG_Info
   ; Execute browser setup routine for user's browser selection
   Call(SetupChrome)
   _WD_Startup()
   If @error <> $_WD_ERROR_Success Then
       Exit -1
   EndIf
EndFunc
_WDStartup: OS: WIN_7 WIN32_NT 7601 Service Pack 1
_WDStartup: AutoIt: 3.3.14.5
_WDStartup: WD.au3: 0.2.0.5
_WDStartup: WinHTTP:    1.6.4.1
_WDStartup: Driver: chromedriver81f.exe
_WDStartup: Params: 
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}
__WD_Post: StatusCode=500; ResponseText={"value":{"error":"unknown error","message":"unknown error: Failed to create Chrome process.","stacktrace":"Backtrace:\n\tOrdinal0 [0x00365F73+2449267]\n\tOrdinal0 [0x00298361+1606497]\n\tOrdinal0 [0x0018F969+522601]\n\tOrdinal0 [0x0011CF6D+53101]\n\tOrdinal0 [0x0013C127+180519]\n\tOrdinal0 [0x0013BF2D+180013]\n\tOrdinal0 [0x00139E5B+171611]\n\tOrdinal0 [0x00121DD8+73176]\n\tOrdinal0 [0x00122E50+77392]\n\tOrdinal0 [0x00122DE9+77289]\n\tOrdinal0 [0x002AD8D7+1693911]\n\tGetHandleVerifier [0x00404036+522726]\n\tGetHandleVerifier [0x00403D74+522020]\n\tGetHandleVerifier [0x00419187+609079]\n\tGetHandleVerifier [0x004048A6+524886]\n\tOrdinal0 [0x002A5CBC+1662140]\n\tOrdinal0 [0x002AF23B+1700411]\n\tOrdinal0 [0x002AF3A3+1700771]\n\tOrdinal0 [0x002C5215+1790485]\n\tBaseThreadInitThunk [0x74C6343D+18]\n\tRtlInitializeExceptionChain [0x772E98B2+99]\n\tRtlInitializeExceptionChain [0x772E9885+54]\n"}}
__WD_Post ==> Timeout: {"value":{"error":"unknown error","message":"unknown error: Failed to create Chrome process.","stacktrace":"Backtrace:\n\tOrdinal0 [0x00365F73+2449267]\n\tOrdinal0 [0x00298361+1606497]\n\tOrdinal0 [0x0018F969+522601]\n\tOrdinal0 [0x0011CF6D+53101]\n\tOrdinal0 [0x0013C127+180519]\n\tOrdinal0 [0x0013BF2D+180013]\n\tOrdinal0 [0x00139E5B+171611]\n\tOrdinal0 [0x00121DD8+73176]\n\tOrdinal0 [0x00122E50+77392]\n\tOrdinal0 [0x00122DE9+77289]\n\tOrdinal0 [0x002AD8D7+1693911]\n\tGetHandleVerifier [0x00404036+522726]\n\tGetHandleVerifier [0x00403D74+522020]\n\tGetHandleVerifier [0x00419187+609079]\n\tGetHandleVerifier [0x004048A6+524886]\n\tOrdinal0 [0x002A5CBC+1662140]\n\tOrdinal0 [0x002AF23B+1700411]\n\tOrdinal0 [0x002AF3A3+1700771]\n\tOrdinal0 [0x002C5215+1790485]\n\tBaseThreadInitThunk [0x74C6343D+18]\n\tRtlInitializeExceptionChain [0x772E98B2+99]\n\tRtlInitializeExceptionChain [0x772E9885+54]\n"}}
_WD_CreateSession: {"value":{"error":"unknown error","message":"unknown error: Failed to create Chrome process.","stacktrace":"Backtrace:\n\tOrdinal0 [0x00365F73+2449267]\n\tOrdinal0 [0x00298361+1606497]\n\tOrdinal0 [0x0018F969+522601]\n\tOrdinal0 [0x0011CF6D+53101]\n\tOrdinal0 [0x0013C127+180519]\n\tOrdinal0 [0x0013BF2D+180013]\n\tOrdinal0 [0x00139E5B+171611]\n\tOrdinal0 [0x00121DD8+73176]\n\tOrdinal0 [0x00122E50+77392]\n\tOrdinal0 [0x00122DE9+77289]\n\tOrdinal0 [0x002AD8D7+1693911]\n\tGetHandleVerifier [0x00404036+522726]\n\tGetHandleVerifier [0x00403D74+522020]\n\tGetHandleVerifier [0x00419187+609079]\n\tGetHandleVerifier [0x004048A6+524886]\n\tOrdinal0 [0x002A5CBC+1662140]\n\tOrdinal0 [0x002AF23B+1700411]\n\tOrdinal0 [0x002AF3A3+1700771]\n\tOrdinal0 [0x002C5215+1790485]\n\tBaseThreadInitThunk [0x74C6343D+18]\n\tRtlInitializeExceptionChain [0x772E98B2+99]\n\tRtlInitializeExceptionChain [0x772E9885+54]\n"}}
_WD_CreateSession ==> Webdriver Exception: HTTP status = 500
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"https://facebook.com"}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00365F73+2449267]\n\tOrdinal0 [0x00298361+1606497]\n\tOrdinal0 [0x0018F812+522258]\n\tOrdinal0 [0x00121949+72009]\n\tOrdinal0 [0x00139F27+171815]\n\tOrdinal0 [0x001389FA+166394]\n\tOrdinal0 [0x001385D4+165332]\n\tOrdinal0 [0x0011232E+9006]\n\tOrdinal0 [0x00112766+10086]\n\tOrdinal0 [0x00112E30+11824]\n\tOrdinal0 [0x002AD8D7+1693911]\n\tGetHandleVerifier [0x00404036+522726]\n\tGetHandleVerifier [0x00403D74+522020]\n\tGetHandleVerifier [0x00419187+609079]\n\tGetHandleVerifier [0x004048A6+524886]\n\tOrdinal0 [0x002A5CBC+1662140]\n\tOrdinal0 [0x001121E2+8674]\n\tOrdinal0 [0x00111F26+7974]\n\tGetHandleVerifier [0x0061357C+2682668]\n\tBaseThreadInitThunk [0x74C6343D+18]\n\tRtlInitializeExceptionChain [0x772E98B2+99]\n\tRtlInitializeExceptionChain [0x772E9885+54]\n"}}
_WD_Navigate: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00365F73+2449267]\n\tOrdinal0 [0x00298361+1606497]\n\tOrdinal0 [0x0018F812+522258]\n\tOrdinal0 [0x00121949+72009]\n\tOrdinal0 [0x00139F27+171815]\n\tOrdinal0 [0x001389FA+166394]\n\tOrdinal0 [0x001385D4+165332]\n\tOrdinal0 [0x0011232E+9006]\n\tOrdinal0 [0x00112766+10086]\n\tOrdinal0 [0x00112E30+11824]\n\tOrdinal0 [0x002AD8D7+1693911]\n\tGetHandleVerifier [0x00404036+522726]\n\tGetHandleVerifier [0x00403D74+522020]\n\tGetHandleVerifier [0x00419187+609079]\n\tGetHandleVerifier [0x004048A6+524886]\n\tOrdinal0 [0x002A5CBC+1662140]\n\tOrdinal0 [0x001121E2+8674]\n\tOrdinal0 [0x00111F26+7974]\n\tGetHandleVerifier [0x0061357C+2682668]\n\tBaseThreadInitThunk [0x74C6343D+18]\n\tRtlInitializeExceptionChain [0x772E98B2+99]\n\tRtlInitializeExceptionChain [0x772E9885+54]\n"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session//refresh; $sData={}
__WD_Post: StatusCode=404; ResponseText={"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00365F73+2449267]\n\tOrdinal0 [0x00298361+1606497]\n\tOrdinal0 [0x0018F812+522258]\n\tOrdinal0 [0x00121949+72009]\n\tOrdinal0 [0x00139F27+171815]\n\tOrdinal0 [0x001389FA+166394]\n\tOrdinal0 [0x001385D4+165332]\n\tOrdinal0 [0x0011232E+9006]\n\tOrdinal0 [0x00112766+10086]\n\tOrdinal0 [0x00112E30+11824]\n\tOrdinal0 [0x002AD8D7+1693911]\n\tGetHandleVerifier [0x00404036+522726]\n\tGetHandleVerifier [0x00403D74+522020]\n\tGetHandleVerifier [0x00419187+609079]\n\tGetHandleVerifier [0x004048A6+524886]\n\tOrdinal0 [0x002A5CBC+1662140]\n\tOrdinal0 [0x001121E2+8674]\n\tOrdinal0 [0x00111F26+7974]\n\tGetHandleVerifier [0x0061357C+2682668]\n\tBaseThreadInitThunk [0x74C6343D+18]\n\tRtlInitializeExceptionChain [0x772E98B2+99]\n\tRtlInitializeExceptionChain [0x772E9885+54]\n"}}
_WD_Action: {"value":{"error":"invalid session id","message":"invalid session id","stacktrace":"Backtrace:\n\tOrdinal0 [0x00365F73+2449267]\n\tOrdinal0 [0x00298361+1606497]\n\tOrdinal0 [0x0018F812+522258]\n\tOrdinal0 [0x00121949+72009]\n\tOrdinal0 [0x00139F27+171815]\n\tOrdinal0 [0x001389FA+166394]\n\tOrdinal0 [0x001385D4+165332]\n\tOrdinal0 [0x0011232E+9006]\n\tOrdinal0 [0x00112766+10086]\n\tOrdinal0 [0x00112E30+11824]\n\tOrdinal0 [0x002AD8D7+1693911]\n\tGetHandleVerifier [0x00404036+522726]\n\tGetHandleVerifier [0x00403D74+522020]\n\tGetHandleVerifier [0x00419187+609079]\n\tGetHandleVerifier [0x004048A6+524886]\n\tOrdinal0 [0x002A5CBC+1662140]\n\tOrdinal0 [0x001121E2+8674]\n\tOrdinal0 [0x00111F26+7974]\n\tGetHandleVerifier [0x0061357C+2682668]\n\tBaseThreadInitThunk [0x74C6343D+18]\n\tRtlInitializeExceptionChain [0x772E98B2+99]\n\tRtlInitializeExceptionChain [0x772E9885+54]\n"}}

 

Edited by VodkaDiva

xxxxxxxxxxx

Posted
15 hours ago, Danp2 said:

That's a very old version of the UDF. Please update and then report back.

You're running WIndows 7 32-bit, correct? What version of Chrome do you have installed?

Thanks danp . i have fix it. because when i remove chrome and not at all . still have 1 forder chrome  => when i install new chrome 81. but that forder make selenium recognize 86 .
Thanks you so much

xxxxxxxxxxx

Posted (edited)

Dear Danp2

Really thank you for your effort .

I would ask how to Attach with web page already exist  ?

How get $sSession for exist web pag???

Func _WD_Attach($sSession, $sString, $sMode = Default)
    Local Const $sFuncName = "_WD_Attach"
    Local $sTabHandle = '', $lFound = False, $sCurrentTab = '', $aHandles

    If $sMode = Default Then $sMode = 'title'

    $aHandles = _WD_Window($sSession, 'handles')

    If @error = $_WD_ERROR_Success Then
        $sMode = StringLower($sMode)
        $sCurrentTab = _WD_Window($sSession, 'window')

        For $sHandle In $aHandles

            _WD_Window($sSession, 'Switch', '{"handle":"' & $sHandle & '"}')

            Switch $sMode
                Case "title", "url"
                    If StringInStr(_WD_Action($sSession, $sMode), $sString) > 0 Then
                        $lFound = True
                        $sTabHandle = $sHandle
                        ExitLoop
                    EndIf

                Case 'html'
                    If StringInStr(_WD_GetSource($sSession), $sString) > 0 Then
                        $lFound = True
                        $sTabHandle = $sHandle
                        ExitLoop
                    EndIf

                Case Else
                    Return SetError(__WD_Error($sFuncName, $_WD_ERROR_InvalidDataType, "(Title|URL|HTML) $sOption=>" & $sMode), 0, $sTabHandle)
            EndSwitch
        Next

        If Not $lFound Then
            ; Restore prior active tab
            If $sCurrentTab <> '' Then
                _WD_Window($sSession, 'Switch', '{"handle":"' & $sCurrentTab & '"}')
            EndIf

            Return SetError(__WD_Error($sFuncName, $_WD_ERROR_NoMatch), 0, $sTabHandle)
        EndIf
    Else
        Return SetError(__WD_Error($sFuncName, $_WD_ERROR_GeneralError), 0, $sTabHandle)
    EndIf

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

Edited by samibb
Posted

Hi @samibb,

The answer depends on your situation, and you haven't provided enough details to know how to correctly answer your question. Please provide the following details --

  • which browser you are using?
  • Is the browser being launched manually or via _WD_CreateSession?

Show us your code showing what you've tried thus far.

Regards,

Dan

P.S. Not sure why you chose to post the code for the _WD_Attach function, but please follow this procedure when posting code in the future.

Posted (edited)
  • which browser you are using?
  • the browser is : Chrome
  • Is the browser being launched manually or via _WD_CreateSession?
  • Yes, should lunched manually .
  •  
  •   Show us your code showing what you've tried thus far
  • Sorry, I am still reading , understanding and testing  wd_demo.au3 program.
  •  
  • Thanks  DANP 
Edited by samibb
Posted (edited)

Anyone know what function I can use to get the URL of the current page. I'm using chromedriver if that makes a difference.

I looked though wd_core.au3 and the wiki but couldn't find a similar method such as the one used in the IE udf

Looking for a chromedriver alternative to this:

_IEPropertyGet($oIE, "locationurl")

 

Edited by NassauSky
Posted
10 hours ago, samibb said:

Yes, should lunched manually

Here's an example --

#include "wd_core.au3"

Local $sDesiredCapabilities, $sSession

ShellExecute("chrome.exe", "--remote-debugging-port=9222")

SetupChrome()
_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "http://yahoo.com")

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": {"debuggerAddress": "localhost:9222"}}}}'
EndFunc

AFAIK, you have to launch Chrome with the --remote-debugging-port option in order to connect to it with Chromedriver after the fact.

Posted (edited)

Dear Danp2

C:\Users\11003813\Desktop\AutoIT\chromedriver.exe

where chromedriver.exe should be?

version (0.3.1.0 ) update it

Edited by samibb
Posted

Dear Danp2

Thank you very match. It works now.

Local $sDesiredCapabilities, $sSession

ShellExecute("chrome.exe", "--remote-debugging-port=9222")

SetupChrome()
_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "http://yahoo.com")

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": {"debuggerAddress": "localhost:9222"}}}}'
EndFunc

I tried but still open new web page.

Sorry i do not know how to   launch Chrome with the --remote-debugging-port option in order to connect to it with Chromedriver after the fact

 

Posted

@samibb There are lots of ways to launch an executable with parameters. Some examples --

  • ShellExecute, which the code above demonstrate
  • From the command line
  • Using a Windows shortcut that points to the executable

You haven't explained the method you are using to initially load Chrome. If you are double clicking an icon or using the Start menu, then that would indicate that you are using the 3rd option above. In this case, you need to modify the shortcut so that it launches Chrome with the additional parameters.

Posted

I've come up against an interesting request.  Is there any way I can select an XPATH (or another form of element selection) that I can have the browser jump to that part of the page.  For example I used the the function _WD_HighlightElement($sSession, $sElement, 1) which highlights the selected element but it doesn't have the browser jump to that part of the page.

Things that make you go hmmm

 

:-/

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