Jump to content
CaptainBeardsEyesBeard

WebDriver help - Starting up chrome and navigating to a page

Recommended Posts

Func Test14_CreateAMatter_WithWD($IEURL)
#RequireAdmin
Local $sDesiredCapabilities
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
sleep(5000)
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars","user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data"] }}}}'
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
If $sSession <> "" Then
    MsgBox(0,"",$sSession)
    _WD_Navigate($sSession, $IEURL)
Else
    msgbox(0,"","Blank sessionid")
EndIf

_WD_DeleteSession($sSession)
_WD_Shutdown()

EndFunc

Hi 

 

I have this code then in my main function I call it like this with the URL defined above 

Test14_CreateAMatter_WithWD($IEURL)

Also have these includes  

;Web driver
#include "C:\DACBAutomationTesting\Automation\WebDriver\wd_core.au3"
#include "C:\DACBAutomationTesting\Automation\WebDriver\wd_helper.au3"

and my output just does this

Any idea? 

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\AutomationTesting\Elite3eAutomationTest\Framework\TestEnv.au3"    
>Exit code: 0    Time: 0.659

 

Share this post


Link to post
Share on other sites

thanks thats ace 

it's now hitting the Else line and bringing that box up without bringing up Chrome  

Else
    msgbox(0,"","Blank sessionid")

 

Func Test14_CreateAMatter_WithWD($IEURL)
Local $sDesiredCapabilities
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
sleep(5000)
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars","user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data"] }}}}'
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
If $sSession <> "" Then
    MsgBox(0,"",$sSession)
    _WD_Navigate($sSession, $IEURL)
Else
    msgbox(0,"","Blank sessionid")
EndIf

_WD_DeleteSession($sSession)
_WD_Shutdown()

EndFunc

and Scite output is

>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\AutomationTesting\Elite3eAutomationTest\Framework\TestEnv.au3"    
_WDStartup: OS: WIN_10 WIN32_NT 17134 
_WDStartup: AutoIt: 3.3.14.4
_WDStartup: WD.au3: 0.1.0.21
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: 
_WDStartup: Port:   9515
_WD_Startup ==> General Error: Error launching web driver!
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":["start-maximized", "disable-infobars","user-data-dir=C:\\Users\\USER\\AppData\\Local\\Google\\Chrome\\User Data"] }}}}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_CreateSession: 0
_WD_CreateSession ==> Webdriver Exception: HTTP status = 0
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"http://testsite/UAT1/web/ui/dashboard"}
__WD_Post: StatusCode=0; ResponseText=0
__WD_Post ==> Send / Recv error
_WD_Navigate: 0
_WD_Navigate ==> Webdriver Exception: HTTP status = 0
__WD_Delete: URL=HTTP://127.0.0.1:9515/session/
__WD_Delete: StatusCode=0; ResponseText=0
__WD_Delete ==> Webdriver Exception
_WD_DeleteSession: 0
_WD_DeleteSession ==> Webdriver Exception: HTTP status = 0
>Exit code: 0    Time: 14.44

 

Share this post


Link to post
Share on other sites

Work the problem... What's the first error shown in the console output? Why might that error be occurring?

Edit: Also noticed that you are using an older version of the UDF. There have been multiple updates released since v0.1.0.21, so you would likely benefit by updating.

Edited by Danp2

Share this post


Link to post
Share on other sites

Change the $sDesiredCapabilities as follows and see if it works. Bear in mind that you must put "goog:" in front of "chromeOptions" and that "disable-infobars" no longer works.  My version below includes an alternative argument to disable the infobar. Regarding the user-data-dir, it used to work and I don't know why it doesn't now under the latest chromedriver. If you find why, please let us know.

Edit: I later found that user-data-dir command line is valid and working.

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

 

Edited by CYCho

Share this post


Link to post
Share on other sites

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...