Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

A widget should only say it #exists? if its validator is present. #10

Merged
merged 2 commits into from

2 participants

@tablatom

Not sure what you guys had in mind for validated_by_presence_of but I figured something like this would be useful.

@sah sah merged commit b547fe0 into saucelabs:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 1 deletion.
  1. +4 −0 lib/test/right/feature.rb
  2. +8 −1 lib/test/right/widget.rb
View
4 lib/test/right/feature.rb
@@ -8,6 +8,10 @@ class Feature
WIDGET_TIMEOUT = 10 # seconds
+ def self.test(name, &b)
+ define_method "test_#{name.gsub(' ', '_')}", &b
+ end
+
def initialize(driver, data)
@driver = driver
@data = data
View
9 lib/test/right/widget.rb
@@ -88,12 +88,19 @@ def visit
def exists?
begin
root
- return true
+ return valid?
rescue WidgetNotPresentError
return false
end
end
+ def valid?
+ validator = self.class.validator
+ validator.nil? || @driver.find_element(validator)
+ rescue Selenium::WebDriver::Error::NoSuchElementError => e
+ false
+ end
+
def validate!(timeout=15)
timeout = Time.now + timeout
while Time.now < timeout
Something went wrong with that request. Please try again.