Jump to content
Danp2

WebDriver UDF - Help & Support

Recommended Posts

I think I have detected a problem in the chrome driver. Indeed in the case of use of a specific profile during the normal shutdown of the program and that I send the following commands;

WD_DeleteSession ($ sSession)
and_WD_Shutdown ()

Chrome closes normally but when reopened I get the following message "Restore pages? Chrome did not shut down properly" <RESTORE>
If I close the program the following way

If ProcessExists ("chrome.exe") Then
$ aList = WinList ()
For $ i = 1 To $ aList [0] [0]
If StringInStr ($ aList [$ i] [0], "Google Chrome")> 0 And BitAND (WinGetState ($ aList [$ i] [1]), 2) Then
Sleep (200)

WinClose ($ aList [$ i] [1])
EndIf
Next
EndIf

If ProcessExists ("chromedriver.exe") Then
Local $ hWnd = WinWait ("[REGEXPTITLE: (chromedriver.exe)]", "", 1)
WinClose ($ hWnd)
EndIf


then the programm restarts without error message

 

Here is the code which allow to test this problem 

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=toto.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Language=1036
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#Au3Stripper_Parameters=/sf /sv
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Opt("MustDeclareVars", 0)
Opt("MouseCoordMode", 1)
Opt("WinTitleMatchMode", 4)
Opt("SendKeyDelay", 100)
Opt("SendKeyDownDelay", 5)
Opt("CaretCoordMode", 0)
Opt("WinWaitDelay", 550)
Opt("MouseClickDelay", 20)
Opt("TrayIconDebug", 1)
Opt("PixelCoordMode", 0)

 Global  $echrome = True
 Global  $Ssession,$sDesiredCapabilities

#include "wd_core.au3"
#include "wd_helper.au3"


;================================================
;Recherche d la langue du systéme d'exploitation
;=============================================


    SetupChrome()

_WD_Startup()
Sleep(1000)


$sSession = _WD_CreateSession($sDesiredCapabilities)
;_WD_Window($sSession, 'Maximize')


    _WD_Navigate($sSession, "http://www.google.com")
    _WD_LoadWait($sSession,  500, -1)
    _WD_DeleteSession($sSession)
    _WD_Shutdown()

Func SetupChrome()
    ;======================================

    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": { "acceptInsecureCerts":true, "unhandledPromptBehavior": "ignore","goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false,"prefs": {"credentials_enable_service": false}, "args":["start-minimized","--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\",  "disable-infobars"]}}}}'
EndFunc   ;==>SetupChrome

After you have to relaunch the programm and you get this message :

image.thumb.png.362600116f92c32e69bddfd019c95a14.png

Edited by loulou2522

Share this post


Link to post
Share on other sites

For easy comprehension I don't use :

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": { "acceptInsecureCerts":true, "unhandledPromptBehavior": "ignore","goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false,"prefs": {"credentials_enable_service": false}, "args":["start-minimized","--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Patrickun", "disable-infobars"]}}}}'

But if you use another profile like me 'partrickun' the problem is the same you can test it 

Maybe i make something tha't is wrong ?

Share this post


Link to post
Share on other sites
10 hours ago, Danp2 said:

@loulou2522 No idea what you're trying to say here. Did you try to locate the post that I referred you to previously? 🤨

State to reproduce my problem :

1- Create on Chrome a new profile ex patrickun

2' Launch the following proogramm and wait for exit 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=toto.exe
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Language=1036
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#Au3Stripper_Parameters=/sf /sv
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Opt("MustDeclareVars", 0)
Opt("MouseCoordMode", 1)
Opt("WinTitleMatchMode", 4)
Opt("SendKeyDelay", 100)
Opt("SendKeyDownDelay", 5)
Opt("CaretCoordMode", 0)
Opt("WinWaitDelay", 550)
Opt("MouseClickDelay", 20)
Opt("TrayIconDebug", 1)
Opt("PixelCoordMode", 0)

 Global  $echrome = True
 Global  $Ssession,$sDesiredCapabilities

#include "wd_core.au3"
#include "wd_helper.au3"


;================================================
;Recherche d la langue du systéme d'exploitation
;=============================================


$_WD_ESCAPE_CHARS = '\\"'


    SetupChrome()

_WD_Startup()
Sleep(1000)


$sSession = _WD_CreateSession($sDesiredCapabilities)
;_WD_Window($sSession, 'Maximize')


    _WD_Navigate($sSession, "http://www.google.com")
    _WD_LoadWait($sSession,  500, -1)
    _WD_DeleteSession($sSession)
    _WD_Shutdown()

Func SetupChrome()
    ;======================================

    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": { "acceptInsecureCerts":true, "unhandledPromptBehavior": "ignore","goog:chromeOptions": {"w3c": true, "excludeSwitches": ["enable-automation"], "useAutomationExtension": false,"prefs": {"credentials_enable_service": false}, "args":["start-minimized","--user-data-dir=C:\\Users\\' & @UserName & '\\AppData\\Local\\Google\\Chrome\\User Data\\", "--profile-directory=Patrickun", "disable-infobars"]}}}}'

EndFunc   ;==>SetupChrome

3- Relaunch the programm again

image.png.58275e4e3a9ec262fa1e99981a8f6d63.pngWhen launching the programm again  you will have an error messsage 

This indicate that's chrome wasn't closed correctly.

4- If i use anaother way to close programm instead of 

_WD_DeleteSession($sSession)
   _WD_Shutdown()

 

    If ProcessExists("chrome.exe") Then
            $aList = WinList()
            For $i = 1 To $aList[0][0]
                If StringInStr($aList[$i][0], "Google Chrome") > 0 And BitAND(WinGetState($aList[$i][1]), 2) Then
                    Sleep(200)
                    WinClose($aList[$i][1])
                EndIf
            Next
        EndIf

    If ProcessExists("chromedriver.exe") Then
        Local $hWnd = WinWait("[REGEXPTITLE:(chromedriver.exe)]", "", 1)
        WinClose($hWnd)
    EndIf

With thats  command Chrome end correctly and if you relaunch another time the programm, you don't have an error message like below.

I explain my problem and hope it will be suffisant because i can't say more abour this problem 

Share this post


Link to post
Share on other sites

@loulou2522 I got all of that from your initial post. I guess your subsequent post was an attempt to add that this also occurs when you create a new profile, correct?

Quote

This has been discussed previously in this same thread and a solution that involved writing changes directly into some of the profile's files was provided.

I'm trying to get you to go find this prior post on your own. Have you done so?

Share this post


Link to post
Share on other sites
1 minute ago, Danp2 said:

@loulou2522 I got all of that from your initial post. I guess your subsequent post was an attempt to add that this also occurs when you create a new profile, correct?

I'm trying to get you to go find this prior post on your own. Have you done so?

Yes when creating a new profile and after when using this profile

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Similar Content

    • By Danp2
      Introduction
      This UDF will allow you to interact with any browser that supports the W3C WebDriver specifications. Supporting multiple browsers via the same code base is now possible with just a few configuration settings.
      Requirements
      JSON UDF https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn
      WinHTTP UDF https://www.autoitscript.com/forum/topic/84133-winhttp-functions/
      WebDriver for desired browser
      Chrome WebDriver https://sites.google.com/a/chromium.org/chromedriver/downloads FireFox WebDriver https://github.com/mozilla/geckodriver/releases Edge WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Function List
      Core Functions
      _WD_CreateSession($sDesiredCapabilities='{}') _WD_DeleteSession($sSession) _WD_Status() _WD_Timeouts($sSession, $sTimeouts = '') _WD_Navigate($sSession, $sURL) _WD_Action($sSession, $sCommand) _WD_Window($sSession, $sCommand, $sOption = '') _WD_FindElement($sSession, $sStrategy, $sSelector, $sStartElement = "", $lMultiple = False) _WD_ElementAction($sSession, $sElement, $sCommand, $sOption='') _WD_ExecuteScript($sSession, $sScript, $sArguments="[]") _WD_Alert($sSession, $sCommand, $sOption = '') _WD_GetSource($sSession) _WD_Cookies($sSession, $sCommand, $sOption = '') _WD_Option($sOption, $vValue = "") _WD_Startup() _WD_Shutdown() Helper Functions
      _WD_NewTab($sSession, $lSwitch = True, $iTimeout = -1, $sURL = "", $sFeatures = "") _WD_Attach($sSession, $sString, $sMode = 'title') _WD_LinkClickByText($sSession, $sText, $lPartial = True) _WD_WaitElement($sSession, $sElement, $sStrategy, $sSelector[, $iDelay = 0[, $iTimeout = -1]]) _WD_GetMouseElement($sSession) _WD_GetElementFromPoint($sSession, $iX, $iY) _WD_LastHTTPResult() _WD_GetFrameCount() _WD_IsWindowTop() _WD_FrameEnter($sIndexOrID) _WD_FrameLeave() _WD_HighlightElement($sSession, $sElement[, $iMethod = 1]) _WD_HighlightElements($sSession, $aElements[, $iMethod = 1]) _WD_jQuerify($sSession) WD_ElementOptionSelect($sSession, $sStrategy, $sSelector, $sStartElement = "") _WD_ConsoleVisible($lVisible = False) _WD_Screenshot($sSession, $sElement = '', $nOutputType = 1) Source Code
      You will always be able to find the latest version in the GitHub Repo 
      Help / Support
      Please post any questions, suggestions or errors in the GH&S thread.
      https://www.autoitscript.com/forum/topic/192730-webdriver-udf-help-support/
    • By Davidowicza
      Hey guys,
      I am creating my very first script that automates a browser (I usually work with program installs and database automation) and have come across an issue that I am totally stumped on. I need to click an element that gives me a drop down list box but the Xpath to the element changes with every instance of chrome I start...
      I have tried selecting the class, rect, and path but no luck. It never finds the element. (I could be doing this wrong since I am not good at HTML)
      Element I need to select:
      This is the Xpath for the last 3 instances of chrome I have run the script with:
      //*[@id="highcharts-5bp9crq-8"]/svg/g[6]/g/rect //*[@id="highcharts-fiw9szv-8"]/svg/g[6]/g/rect //*[@id="highcharts-5szkmx8-8"]/svg/g[6]/g/rect As you can see the path changes every time.
      How I am trying to select the element:
      ;Check for box element _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='highcharts-5bp9crq-8']/svg/g[6]/g") MsgBox(0, "", "check for timeout") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='highcharts-5bp9crq-8']/svg/g[6]/g") _WD_ElementAction($sSession, $sElement, 'click') Maybe someone has come across this before and found a work around without using mouseclick()
      Thanks guys, hopefully I am just very overlooking something simple and can be pointed to the right solution.
      Side Note: I wish I could share the webpage entirety, but it has sensitive information with my agency that I cannot share. If you need more, just let me know and I will try and post as much as I can.
    • By daluu
      This is kind of already posted here:
      '?do=embed' frameborder='0' data-embedContent>>
      but wanted to note this in this forum of example scripts in case some people only look in this forum for examples and not the other forums with respect to AutoIt integration or relation to Selenium WebDriver.
      So, the example in summary is: you can use Selenium WebDriver API to do AutoIt GUI automation (the ControlXyz() and WinXyz() functons, along with mouse and "send keys" functions). Although I suppose that might be opposite or counter to what most examples here are about - using AutoIt to do or control other stuff rather than using other stuff to control/run AutoIt. But regardless, it is an example implementation of a different use case for AutoIt beyond the general AutoIt community, like those who also use Selenium WebDriver and/or need to integrate Selenium with AutoIt for remote deployment.
      https://github.com/daluu/AutoItDriverServer
      with specific demo examples here:
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/CalculatorTest.java
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/calculator.py
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/SeleniumIntegrationTest.java
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/SeleniumIntegrationWithAutoItDriver.py
×
×
  • Create New...