Sha256: 67c9a9461a629b345d643b91dc0a74b5ac721ba3e27722dbbaf9b9df52859ba1
Contents?: true
Size: 1.83 KB
Versions: 1
Compression:
Stored size: 1.83 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 || {} http_client = Selenium::WebDriver::Remote::Http::Default.new http_client.timeout = 120 # seconds @driver = if selenium_server Selenium::WebDriver.for :remote, :url => selenium_server, :desired_capabilities => browser.to_sym, :http_client => http_client else Selenium::WebDriver.for browser.to_sym, options.merge(:http_client => http_client) 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.1 | lib/jasmine/selenium_driver.rb |