Ruby/Watir : firefox headless
If you are using Watir 6.9 you can try:
omg3r = Watir::Browser.new :firefox, profile: 'omg3r', headless: true
http://watir.com/watir-6-9/
How do I run Firefox browser headless with my Ruby script?
I would look at using Watir-Webdriver instead of just plain Watir or Fire-watir. Especially since the only way to work with newer versions of firefox is going to be via Watir-Webdriver.
There's an earlier SO question where the answer covers just this sort of thing, so I'd suggest trying what is described there there first. Can I use Watir to scrape data from a website on a linux server without monitor?
Also since I now know you are using Mac OS, the advice in this thread from the webdriver google group might be more applicable to you
multiple headless firefox instances using watir-webdriver within rails application
I found out that I can use the CGI module to do my work. Since I didnt need a rails application, I used ruby CGI to call the ruby script and pass parameters through URL. I can also launch multiple instances in a non-blocking fashion using this approach. I had to re-write my controller as a stand alone ruby program in order to do this.
Can't upload file using Watir, Headless Browser, Chromedriver, using Ruby
Shouldn't path
variable contain the path to actual file? From your example it looks like it's pointing to parent directory. Ditch the File.dirname(photo)
turning it to this:
photo = File.open("00909_8qYJaR8wTix_600x450.jpg", "a")
path = File.expand_path(photo)
browser.file_field(:type,"file").set(path)
and you should be fine, in my opinion.
Related Topics
Config Undefined in Environment Specific Configuration Files
How to Use String Methods on Utf-8 Characters
How to Upgrade Rvm When the Official Way Doesn't Work
Http.Post_Form in Ruby with Custom Headers
Trouble on Eager Loading "Second Degree" Associated Objects
Ruby Gsub Problem When Using Backreference and Hashes
Delayed_Job: Job Failed to Load: Uninitialized Constant Syck::Syck
Why Does Trying to Use Grape with Rails Fail with "Uninitialized Constant API"
Rational - Original Numbers in Ruby
Regex Negative Lookbehind in Ruby Doesn't Seem to Work
Execute Code Once Sinatra Server Is Running
Ruby on Rails Workflow Engine (Like Ibm Workflow)
Rails Cannot Find Model with Same Name as Ruby Class
How to Serialize as Activesupport::Hashwithindifferentaccess Anymore