Sha256: 8abe66dfe9ae20aef743f3733d77de3723fea8ee06149771dd37ce1494fff22f
Contents?: true
Size: 1.62 KB
Versions: 5
Compression:
Stored size: 1.62 KB
Contents
module Jasmine class SeleniumDriver def initialize(browser, http_address) require 'selenium-webdriver' 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 tests_have_finished? @driver.execute_script("return window.jasmine.getEnv().currentRunner.finished") == "true" end def connect @driver.navigate.to @http_address end def disconnect @driver.quit end def run until tests_have_finished? do sleep 0.1 end puts @driver.execute_script("return window.results()") failed_count = @driver.execute_script("return window.jasmine.getEnv().currentRunner.results().failedCount").to_i failed_count == 0 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
5 entries across 5 versions & 1 rubygems