I'm using Watir in a Ruby script to automatically download some files and I have a little problem :

If Firefox is already running, I get a "permission denied" error when I try to load firefox default profile. I know it's quite normal... But I really need my firefox default profile.

So my question is :

  • Is there any solution to access the default profile even if firefox is already running ?
  • If not, when firefox isn't running and so when I have no error, how can I export the profile I load in my Watir browser (in a text file) ? (for using it later if firefox is already running)

Something like above :

Mozilla = Watir::Browser.new(:firefox, :profile => "default")
file = File.open("path", 'w')
file.write(Mozilla.export_profile())

and then in another script :

profile = Selenium::WebDriver::Firefox::Profile.new(File.read("path"))
Mozilla = Watir::Browser.new(:firefox, :profile => profile)

Or I have to export (and then load) each property one by one ?

有帮助吗?

解决方案

the behaviour you are seeing is normal and correct.
The are two way to work around his:

  1. create a new profile dedicated to Webdriver scripts (using Firefox), and use it. This will keep cache and cookies from one test to another.
  2. if you do not choose any profile, a new, clean profile is created each time you start Webdriver, and it is deleted at the end. This is slower and do not keep any memory from previous runs.

The choice depends on what you need.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top