Sha256: 5d12cc3522b19473a2fe4203bcef20bda42e122a8550c09ff710e5a0e6e0233e
Contents?: true
Size: 1.66 KB
Versions: 1
Compression:
Stored size: 1.66 KB
Contents
module Jasmine class SeleniumDriver def initialize(browser, http_address) require 'selenium-webdriver' ::Selenium::WebDriver::Driver.send(:attr_accessor, :bridge) ::Selenium::WebDriver::Remote::Bridge.send(:attr_accessor, :http) ::Selenium::WebDriver::Remote::Http::Default.send(:attr_accessor, :server_url) selenium_server = if ENV['SELENIUM_SERVER'] ENV['SELENIUM_SERVER'] elsif ENV['SELENIUM_SERVER_PORT'] "http://localhost:#{ENV['SELENIUM_SERVER_PORT']}/wd/hub" end options = if browser == "firefox" && ENV["JASMINE_FIREBUG"] require File.join(File.dirname(__FILE__), "firebug/firebug") profile = Selenium::WebDriver::Firefox::Profile.new profile.enable_firebug {:profile => profile} end || {} @driver = if selenium_server Selenium::WebDriver.for :remote, :url => selenium_server, :desired_capabilities => browser.to_sym else Selenium::WebDriver.for browser.to_sym, options end @http_address = http_address end def connect wdsid = @driver.bridge.session_id wduri = @driver.bridge.http.server_url wdurl = "#{wduri.scheme}://#{wduri.host}:#{wduri.port}/wd/hub" url = "#{@http_address}?wdurl=#{URI.encode(wdurl)}&wdsid=#{URI.encode(wdsid)}" @driver.navigate.to url url end def disconnect @driver.quit end def eval_js(script) result = @driver.execute_script(script) JSON.parse("{\"result\":#{result}}", :max_nesting => false)["result"] end def json_generate(obj) JSON.generate(obj) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rally-jasmine-1.2.0 | lib/jasmine/selenium_driver.rb |