Ruby/Watir:Firefox Headless

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



Leave a reply



Submit