开发者

Segmentation fault issues (selenium-webdriver + rb-appscript)

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').activat开发者_开发知识库e
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


Apologies for not addressing your question directly, but as a workaround you could check out Watir: http://watir.com/. I'm using it successfully with Firefox on Mac OSX 10.6.8. Something along the lines of:

require "rubygems"
require "watir-webdriver"

b = Watir::Browser.new :firefox
b.goto("http://google.com")


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜