Jump to content

Webdriver using your own Firefox profile


Go to solution Solved by Danp2,

Recommended Posts

Hello,

 

I have been using webdriver on my program quite a lot last few years and everything have been working well.

Recently, i have encountered a problem; someone was using my program and his pdf wouldn't open with Firefox.

After some research, i have found out that this is something the file "handlers.json" from Firefox profile folder handle.

So i created a new Firefox profile and i tried to open a new Webdriver session using this profile.

And just by trying to use a specific profile, i'm getting an error.

Here is my current code :

_WD_Option('Driver', @ScriptDir&'\include\'&(@Compiled?'':'Exe_externe\')&'geckodriver.exe')
                _WD_Option('DriverParams', '--log trace ')
                _WD_Option('Port', 4444)
                _WD_CapabilitiesStartup()
                _WD_CapabilitiesAdd("alwaysMatch")
                _WD_CapabilitiesAdd("browserName", "firefox")
                _WD_CapabilitiesAdd("acceptInsecureCerts", "true")
                _WD_CapabilitiesAdd("firstMatch", "firefox")
                _WD_CapabilitiesAdd('args', "about:blank")
                _WD_CapabilitiesAdd('args', '-profile')
                _WD_CapabilitiesAdd('args', "C:\Users\JOUGLET-06303\AppData\Roaming\Mozilla\Firefox\Profiles\6ldwjadu.Profile") 
                $sDesiredCapabilities = _WD_CapabilitiesGet()
                $oSelf.sWDSession=_WD_CreateSession($sDesiredCapabilities)
                if $oSelf.sWDSession=="" then
                    ConsoleWrite("failed")
                Else
                    ConsoleWrite("success")
                Endif

Those 2 lines are the only lines i added from what i had before, which trigger the error i get (without those 2 line, everything work well) :

_WD_CapabilitiesAdd('args', '-profile')
_WD_CapabilitiesAdd('args', "C:\Users\JOUGLET-06303\AppData\Roaming\Mozilla\Firefox\Profiles\6ldwjadu.ProWeb")

Error log :

_WD_Option ==> Success [0] : Parameters:   Option=Driver   Value=C:\ProWeb\Projets\ProWeb\version\include\Exe_externe\geckodriver.exe
_WD_Option ==> Success [0] : Parameters:   Option=DriverParams   Value=--log trace 
_WD_Option ==> Success [0] : Parameters:   Option=Port   Value=4444
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [alwaysMatch] 
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully used [firstMatch]  with specified browser: firefox
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_CapabilitiesAdd ==> Success [0] : Successfully added capability
_WD_GetFreePort ==> Success [0 / 4444] : Parameters:   MinPort=4444   MaxPort=Default
_WD_IsLatestRelease ==> Success [0] : True
_WD_Startup: OS:    WIN_10 X64 19045 
_WD_Startup: AutoIt:    3.3.16.1
_WD_Startup: Webdriver UDF: 1.3.1 (Up to date)
_WD_Startup: WinHTTP:   1.6.4.2
_WD_Startup: Driver:    C:\ProWeb\Projets\ProWeb\version\include\Exe_externe\geckodriver.exe (64 Bit)
_WD_Startup: Params:    --log trace 
_WD_Startup: Port:  4444
_WD_Startup: Command:   "C:\ProWeb\Projets\ProWeb\version\include\Exe_externe\geckodriver.exe" --log trace  
_WD_Startup ==> Success [0]
0 / 0
__WD_Post ==> Send / Recv error [6] : HTTP status = 0
_WD_CreateSession ==> Webdriver Exception [10]

I have tried to replace the slash "\" from profile path to "/" and still same result.

 

If anyone has an idea i would really appreciate !

Link to comment
Share on other sites

Thank you !

It work this way :

_WD_Option('Driver', @ScriptDir&'\include\'&(@Compiled?'':'Exe_externe\')&'geckodriver.exe')
_WD_Option('DriverParams', '--log trace ')
_WD_Option('Port', 4444)
_WD_Option('DriverParams', '--marionette-port 2828')
$sDesiredCapabilities = '{"capabilities":{"alwaysMatch": {"moz:firefoxOptions": {"args": ["about:blank", "-profile", "C:/ProWeb/Projets/ProWeb/version/scénarios/k736nmka.default"],"log": {"level": "trace"},"prefs": {"browser.download.improvements_to_download_panel": false}}}}}'

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...