I'm trying to automate webscraping, making use of both the selenium-webdriver
and the ruby port of AppleScript rb-appscript
. However, when I try to run the code I keep running into a segmentation fault.
Code:
require 'rubygems'
require 'appscript'; include Appscript
require 'selenium-webdriver'
# Open instance of Firefox
driver = Selenium::WebDriver.for(:firefox, :profile => "default")
# Open my webscraping extension
app('Firefox').activate
app("System Events").processes["firefox-bin"].menu_bars[1].menu_bar_items["Tool\
s"].menus["Tools"].menu_items["******"].click
driver.navigate.to "http://google.com"
driver.quit
This line:
driver = Selenium::WebDriver.for(:firefox, :profile => "default")
Seems to be causing the issue.
When executed in separate files, the two work fine.
selenium-webdriver:
require 'rubygems'
require 'selenium-webdriver'
driver = Selenium::WebDriver.for(:firefox, :profile => "default")
driver.navigate.to "http://google.com"
driver.quit
rb-appscript:
require 'rubygems'
require 'rb-appscript'; include Appscript
app('Firefox').activate
app("System Events").processes["firefox-bin"].menu_bars[1].menu_bar_items["Tool\
s"].menus["Tools"].menu_items["******"].click
Any idea what the issue is? I'm new at ruby so I'm not exactly sure what is causing the issue.
Ruby version: 1.8.7 (2011-06-30 patch level352) OS: Mac OSX 10.6.8 64-bit
Looks like the version of ruby was causing the issue. 1.8.7 is a bridge between 1.8 and 1.9, and is not recommended for use apparently. There are numerous reports of ruby 1.8.7 causing segmentation faults when using a multitude of different gems. Upgrading to the latest version (1.9.2) fixed the issue!