Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ source "https://rubygems.org"
gemspec

group :development do
gem 'watir-webdriver'
gem 'watir'
gem 'rdoc'
gem 'rspec', '2.99'
gem 'rake'
gem 'bundler'
gem 'mocha', '0.12.8', :require => false
gem 'cucumber'
gem 'gherkin'
gem 'cucumber', '2.99.0'
gem 'gherkin', '~>4.0'
gem 'rspec-mocks'
gem 'simplecov'
end
2 changes: 1 addition & 1 deletion generators/new_project/templates/gemfile.rb.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source "https://rubygems.org"

gem 'watirmark', :git => 'https://github.com/convio/watirmark.git'
gem 'watir-webdriver'
gem 'watir'
gem 'rspec'
gem 'rake'
gem 'builder'
Expand Down
2 changes: 1 addition & 1 deletion lib/watirmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Watirmark::Configuration.instance.reload

require 'watirmark/at_exit'
require 'watir-webdriver'
require 'watir'
require 'watirmark/extensions/webdriver_extensions'
require 'watirmark/extensions/ruby_extensions'
require 'watirmark/session'
Expand Down
4 changes: 3 additions & 1 deletion lib/watirmark/controller/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,15 @@ def after_keyword(keyed_element)
end

def populate_keyword_value(keyed_element)
Watirmark.logger.info"Attempting to populate the keyword [#{keyed_element.keyword}] with value [#{value(keyed_element)}]"
call_method_if_exists("populate_#{keyed_element.keyword}") do
@view.send(keyed_element.keyword).wait_until_present
@view.send(keyed_element.keyword).wait_until(&:present?)
@view.send("#{keyed_element.keyword}=", value(keyed_element))
end
end

def verify_keyword_value(keyed_element)
Watirmark.logger.info"Attempting to verify the keyword [#{keyed_element.keyword}] matches [#{value(keyed_element)}]"
call_method_if_exists("verify_#{keyed_element.keyword}") do
keyed_element.get.wait_until_present
assert_equal(keyed_element.get, value(keyed_element))
Expand Down
100 changes: 56 additions & 44 deletions lib/watirmark/extensions/webdriver_extensions.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'watir-webdriver/extensions/select_text'
require 'watir/elements/select'

module Watir

Expand Down Expand Up @@ -48,10 +48,10 @@ def download_links(*args)
end
end

module Atoms
ATOMS[:getPreviousSibling] = File.read(File.expand_path("../atoms/getPreviousSibling.js", __FILE__))
ATOMS[:getNextSibling] = File.read(File.expand_path("../atoms/getNextSibling.js", __FILE__))
end
# module Atoms
# ATOMS[:getPreviousSibling] = File.read(File.expand_path("../atoms/getPreviousSibling.js", __FILE__))
# ATOMS[:getNextSibling] = File.read(File.expand_path("../atoms/getNextSibling.js", __FILE__))
# end

class Table < HTMLElement
def each
Expand All @@ -61,12 +61,14 @@ def each

class TableRow < HTMLElement
def each
cells.each { |x| yield x }
# TODO: not 100% sure this is a complete fix
tds.each { |x| yield x }
end

def column(what)
column = 0
parent.th(:text => what).when_present.parent.cells.each do |cell|
# TODO: not 100% sure this is a complete fix
parent.th(:text => what).when_present.parent.ths.each do |cell|
if what.kind_of? String
return self[column] if cell.text == what
else
Expand All @@ -86,7 +88,12 @@ class Radio < Input
alias :old_radio_set :set

def set(value=nil)
@selector.update(:value => value.to_s) if value
if value
@selector.update(:value => value.to_s)
build
locate
end

old_radio_set
end

Expand All @@ -95,7 +102,12 @@ def set(value=nil)
alias :old_radio_set? :set?

def set?(value=nil)
@selector.update(:value => value.to_s) if value
if value
@selector.update(:value => value.to_s)
build
locate
end

old_radio_set?
end
end
Expand All @@ -111,38 +123,38 @@ def getAllContents

class Element

def next_sibling
e = locate_dom_element(:getNextSibling)
e.nil? ? element(xpath: './following-sibling::*') : e
end
# def next_sibling
# e = locate_dom_element(:getNextSibling)
# e.nil? ? element(xpath: './following-sibling::*') : e
# end
alias_method :nextsibling, :next_sibling

def previous_sibling
e = locate_dom_element(:getPreviousSibling)
e.nil? ? element(xpath: './preceding-sibling::*') : e
end
alias_method :prev_sibling, :previous_sibling
#
# def previous_sibling
# e = locate_dom_element(:getPreviousSibling)
# e.nil? ? element(xpath: './preceding-sibling::*') : e
# end
# alias_method :prev_sibling, :previous_sibling
alias_method :prevsibling, :previous_sibling

def locate_dom_element(method)
assert_exists

e = element_call { execute_atom method, @element }

if e.kind_of?(Selenium::WebDriver::Element)
Watir.element_class_for(e.tag_name.downcase).new(@parent, :element => e)
end
end

alias_method :old_element_call, :element_call
def element_call &block
old_element_call &block
rescue Selenium::WebDriver::Error::UnknownError => ex
raise unless ex.message.include?("Element is not clickable at point")
reset!
assert_exists
retry
end
# def locate_dom_element(method)
# assert_exists
#
# e = element_call { execute_atom method, @element }
#
# if e.kind_of?(Selenium::WebDriver::Element)
# Watir.element_class_for(e.tag_name.downcase).new(@parent, :element => e)
# end
# end

# alias_method :old_element_call, :element_call
# def element_call &block
# old_element_call &block
# rescue Selenium::WebDriver::Error::UnknownError => ex
# raise unless ex.message.include?("Element is not clickable at point")
# reset!
# assert_exists
# retry
# end

alias_method :old_text, :text
def text
Expand All @@ -164,13 +176,13 @@ def check_deprecation(element)
end
end

class IFrame < HTMLElement
alias_method :old_switch_to!, :switch_to!
def switch_to!
class FramedDriver
alias_method :old_switch!, :switch!
def switch!
retry_attempts ||= 0
old_switch_to!
rescue Watir::Exception::UnknownFrameException
# UnknownFrameException is workaround for- https://code.google.com/p/chromedriver/issues/detail?id=948
old_switch!
rescue Selenium::WebDriver::Error::StaleElementReferenceError
# TODO: see why this is a problem and port to watir
retry_attempts += 1
retry if retry_attempts == 1
end
Expand Down
4 changes: 2 additions & 2 deletions lib/watirmark/models/cucumber_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def format_value(value)

def insert_model(text)
# cucumber 2.0 defines a Core module between Cucumber and Ast
doc_class = Cucumber::Ast.const_defined?(:DocString) ? Cucumber::Ast::DocString : Cucumber::Core::Ast::DocString
return text unless text.is_a?(String) || text.is_a?(doc_class)
# doc_class = Cucumber::Core::Ast.const_defined?(:DocString) ? Cucumber::Ast::DocString : Cucumber::Core::Ast::DocString
return text unless text.is_a?(String) || text.is_a?(Cucumber::Core::Ast::DocString)
result = text
method_regexp = /\[([^\[\]]+)\]\.(\w+)/
model_regexp = /\[([^\[\]]+)\]/
Expand Down
28 changes: 14 additions & 14 deletions lib/watirmark/page/keyed_element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ def set val
element = get
val = @map.lookup(val) if @map
case val
when 'nil'
element.clear # workaround to empty element values
when 'nil'
element.clear # workaround to empty element values
else
case element
when Watir::Radio
element.set val
when Watir::CheckBox
val ? element.set : element.clear
when Watir::Select
element.select (val.is_a? Integer) ? val.to_s : val
when Watir::Button
element.click
else
case element
when Watir::Radio
element.set val
when Watir::CheckBox
val ? element.set : element.clear
when Watir::Select
element.select val
when Watir::Button
element.click
else
element.value = val
end
element.value = val
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/watirmark/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def sauce_config(sb)
end

def initialize_page_checkers
POST_WAIT_CHECKERS.each { |p| Page.browser.add_checker p }
POST_WAIT_CHECKERS.each { |p| Page.browser.after_hooks.add p }
end

end
Expand Down
2 changes: 1 addition & 1 deletion lib/watirmark/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Watirmark
module Version
STRING = '5.29.4'
STRING = '6.0.0'
end
end
4 changes: 2 additions & 2 deletions watirmark.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Gem::Specification.new do |s|
s.test_files = Dir['spec/**/*.rb']
s.executables = 'watirmark'
s.require_paths = %w(lib)
s.add_dependency('watir-webdriver', '~> 0.8')
s.add_dependency('watir')
s.add_dependency('american_date', '~> 1.1.0')
s.add_dependency('logger', '~> 1.2.8')
s.add_dependency('logger')
s.add_dependency('uuid', '~> 2.3.7')
s.add_dependency('nokogiri', '~> 1.6.0')
s.add_dependency('thor', '~> 0.19.1')
Expand Down