Skip to content
Browse files

Merge branch 'master' of git@github.com:a-e/rsel

  • Loading branch information...
2 parents f0484cd + 49cb6f2 commit b907956442ffc027817e7cbdd87141a3c657d4f0 @Ken-g6 Ken-g6 committed Apr 6, 2012
Showing with 82 additions and 21 deletions.
  1. +1 −0 .yardopts
  2. +11 −1 docs/history.md
  3. +1 −1 docs/scoping.md
  4. +47 −11 docs/studying.md
  5. +7 −4 lib/rsel/selenium_test.rb
  6. +13 −2 lib/rsel/support.rb
  7. +2 −2 rsel.gemspec
View
1 .yardopts
@@ -9,6 +9,7 @@ docs/usage.md
docs/fitnesse.md
docs/locators.md
docs/scoping.md
+docs/studying.md
docs/examples.md
docs/custom.md
docs/scenarios.md
View
12 docs/history.md
@@ -1,11 +1,21 @@
Rsel History
============
+0.1.2
+-----
+
+- Studying: customizable optimization to improve performance
+- More scoping (see, do_not_see, see_within_seconds, do_not_see_within_seconds)
+- Alert verification (see_alert_within_seconds)
+- Glob and regex can now be used in more places (selenium_compare)
+
+
+
0.1.1
-----
- Conditional expressions (if_is, if_i_see, if_parameter, otherwise, end_if)
-- Temporal visibility (see|do_not_see)_within_seconds
+- Temporal visibility (see_within_seconds, do_not_see_within_seconds)
- Generic field equality (generic_field_equals)
- Generic field fill-in (set_field, set_field_among)
- Hash-based field fill-in (set_fields, sef_fields_among)
View
2 docs/scoping.md
@@ -141,5 +141,5 @@ have a use case that isn't covered by the existing scopes, please [submit an
issue](http://github.com/a-e/rsel/issues), or better yet, implement it yourself
and submit a pull request. See [Development](development.md) for more info.
-Next: [Examples](examples.md)
+Next: [Studying](studying.md)
View
58 docs/studying.md
@@ -3,38 +3,74 @@ Studying
What is studying?
-----------------
-Studying is looking at some material to recall it more easily later. No, really! In this case, studying refers to a process that sends the entire web page from the browser to the Rsel server for further analysis. The name is based on Perl's `study' command.
+Studying is looking at some material to recall it more easily later. No,
+really! In this case, studying refers to a process that sends the entire web
+page from the browser to the Rsel server for further analysis. The name is
+based on Perl's `study` command.
Why would I want to study? (I'm not in school anymore!)
--------------------------------------------------------
-The main reason for studying is that Internet Explorer works with pages, and xpaths in particular, very slowly. It so happens that the xpaths sent by normal Rsel commands are particularly slow to process. Studying can make your test run five times as fast or more!
+The main reason for studying is that Internet Explorer works with pages, and
+xpaths in particular, very slowly. It so happens that the xpaths sent by
+normal Rsel commands are particularly slow to process. Studying can make your
+test run five times as fast or more!
Wow! What's the catch?
-----------------------
-The catch is that when you study, you may not be aware of what's going on around you. While studying, if the page changes on the web browser, you often won't see those changes. This can lead to failed identification of controls, or worse, misidentifications.
+The catch is that when you study, you may not be aware of what's going on
+around you. While studying, if the page changes on the web browser, you often
+won't see those changes. This can lead to failed identification of controls,
+or worse, misidentifications.
-The other, minor catch is that you could wind up spending more time sending data (entire web pages) than you save by studying.
+The other, minor catch is that you could wind up spending more time sending
+data (entire web pages) than you save by studying.
Alright, I'll be careful. How do I use studying?
-------------------------------------------------
-There are two ways, the easy way and the efficient way. The efficient way is to identify blocks where you are doing a lot of work on one page, but the HTML content of a page won't change. Then place a `begin_study` call before the block, and an `end_study` call after it.
+There are two ways, the easy way and the efficient way. The efficient way is
+to identify blocks where you are doing a lot of work on one page, but the HTML
+content of a page won't change. Then place a `begin_study` call before the
+block, and an `end_study` call after it.
What happens if I forget about end_study?
-----------------------------------------
-Don't worry: studying is smart enough to notice certain commands that indicate major page changes, such as page_loads_in_seconds_or_less and see_within_seconds. Of course, this could also lead to your study blocks ending before you expect them to, but such commands almost always mean a study block should end.
+Don't worry: studying is smart enough to notice certain commands that indicate
+major page changes, such as `page_loads_in_seconds_or_less` and
+`see_within_seconds`. Of course, this could also lead to your study blocks
+ending before you expect them to, but such commands almost always mean a study
+block should end.
That's nice, but adding all those blocks sounds like a pain. What's the easy way?
------------------------------------
-The easy way is to set a minimum number of fields which, when worked with at once, will be studied before the work starts. You do this with either the `study` option when initializing Rsel or with the `set_fields_study_min` command within Rsel. Zero, the default, means to never study. Setting the value to 10, for instance, would mean that when one command works with 10 or more different fields at once, a study would happen before the work begins. Right now, only the `set_fields` and `fields_equal` classes of commands can work with so many different fields at once.
+----------------------------------------------------------------------------------
+The easy way is to set a minimum number of fields which, when worked with at
+once, will be studied before the work starts. You do this with either the
+`study` option when initializing Rsel or with the `set_fields_study_min`
+command within Rsel. Zero, the default, means to never study. Setting the
+value to 10, for instance, would mean that when one command works with 10 or
+more different fields at once, a study would happen before the work begins.
+Right now, only the `set_fields` and `fields_equal` classes of commands can
+work with so many different fields at once.
What if I set set_fields_study_min to 1? Does it...study for every command?
----------------------------------------------------------------------------
-Almost. Along with the set_fields and fields_equal commands mentioned above, every command that uses an xpath of 100 characters or more gets studied. (This bit is currently hard-coded; I may modify it in future versions.) Some commands are also known not to affect the page text, like `see` or `get_text`. These do not trigger re-studying for the next command. Even if set_fields_study_min is greater than 1, commands after a `fields_equal` may also benefit from the studying done in that command.
+Almost. Along with the set_fields and fields_equal commands mentioned above,
+every command that uses an xpath of 100 characters or more gets studied. (This
+bit is currently hard-coded; I may modify it in future versions.) Some
+commands are also known not to affect the page text, like `see` or `get_text`.
+These do not trigger re-studying for the next command. Even if
+`set_fields_study_min` is greater than 1, commands after a `fields_equal` may
+also benefit from the studying done in that command.
Too long; didn't read. Can't I just say "go fast" or something?
----------------------------------------------------------------
-Pretty much. Add the "study:auto" value to the Rsel initialization hash.
+Pretty much. Add the `study:auto` value to the Rsel initialization hash.
Sweet, most of my tests are fast on IE! But some now fail.
-----------------------------------------------------------
-Auto-studying works very hard to be transparent and invisible, but rarely it fails. For sections like this, you can turn off studying with `set_fields_study_min(0)` or `set_fields_study_min('never')`. You can later go back to what you set in the initialization with `set_fields_study_min('default')`.
+Auto-studying works very hard to be transparent and invisible, but rarely it
+fails. For sections like this, you can turn off studying with
+`set_fields_study_min(0)` or `set_fields_study_min('never')`. You can later go
+back to what you set in the initialization with
+`set_fields_study_min('default')`.
+
+Next: [Examples](examples.md)
View
11 lib/rsel/selenium_test.rb
@@ -48,10 +48,10 @@ class SeleniumTest
# little disk space you may want to avoid this. Screenshots may not
# be displayed in Internet Explorer.
# @option options [String, Integer] :study
- # How many steps have to be done at once to force studying. Default
- # is `Never` (0). Other accepted strings are `Always' (1), `Auto(matic)`
- # (10 for most browsers and 1 for Internet Explorer), or an integer.
- # Unrecognized strings result in the default.
+ # How many steps have to be done at once to force studying. Default is
+ # `'Never'` (0). Other accepted strings are `'Always'` (1), `'Auto'`
+ # (matic) (10 for most browsers and 1 for Internet Explorer), or an
+ # integer. Unrecognized strings result in the default.
# @option options [String, Integer] :timeout
# Default timeout in seconds. This determines how long the `open` method
# will wait for the page to load, as well as the default timeout for
@@ -66,6 +66,7 @@ class SeleniumTest
# | script | selenium test | http://site.to.test/ | !{host:192.168.0.3} |
# | script | selenium test | http://site.to.test/ | !{host:192.168.0.3, port:4445} |
# | script | selenium test | http://site.to.test/ | !{stop_on_failure:true} |
+ # | script | selenium test | http://site.to.test/ | !{study:Auto} |
#
def initialize(url, options={})
# Strip HTML tags from URL
@@ -524,6 +525,8 @@ def do_not_see_title(title)
# | see alert | Illegal operation! Authorities have been notified. | within | 15 | seconds |
# Validates that the next alert that appears within the given timeout is as specified.
#
+ # @since 0.1.2
+ #
def see_alert_within_seconds(text=nil, seconds=-1)
return skip_status if skip_step?
# Handle the case of being given seconds, but not text.
View
15 lib/rsel/support.rb
@@ -175,6 +175,8 @@ def escape_for_hash(text)
# Normalize the given hash of name => locator mappings.
# Converts all keys to lowercase and calls {#escape_for_hash} on them.
#
+ # @since 0.1.1
+ #
def normalize_ids(ids)
ids = {} unless ids.is_a? Hash
ids.keys.each do |key|
@@ -202,10 +204,11 @@ def strip_tags(text)
return text.gsub(/<\/?[^>]*>/, '')
end
- # This module defines helper methods for building XPath expressions
- # copied from Kelp::XPaths
# Return an XPath for any table row containing all strings in `texts`,
# within the current context.
+ #
+ # @since 0.1.1
+ #
def xpath_row_containing(texts)
texts = [texts] if texts.class == String
conditions = texts.collect do |text|
@@ -222,6 +225,8 @@ def xpath_row_containing(texts)
# xpath_sanitize("Bob's")
# # => concat('Bob', "'", 's')
#
+ # @since 0.1.1
+ #
def xpath_sanitize(text)
# If there's nothing to escape, just wrap text in single-quotes
if !text.include?("'")
@@ -234,6 +239,7 @@ def xpath_sanitize(text)
# Convert a string like "yes", "true", "1", etc.
# Values currently recognized as true, case-insensitive:
+ #
# * [empty string]
# * 1
# * Check
@@ -243,6 +249,9 @@ def xpath_sanitize(text)
# * Selected
# * True
# * Yes
+ #
+ # @since 0.1.1
+ #
def string_is_true?(s)
return /^(?:yes|true|on|(?:check|select)(?:ed)?|1|)$/i === s
end
@@ -254,6 +263,8 @@ def string_is_true?(s)
# @param [String] expected
# Another string. This one may have glob:, regexp:, etc.
#
+ # @since 0.1.1
+ #
def selenium_compare(text, expected)
if expected.sub!(/^regexp:/, '')
return /#{expected}/ === text
View
4 rsel.gemspec
@@ -1,12 +1,12 @@
Gem::Specification.new do |s|
s.name = "rsel"
- s.version = "0.1.1"
+ s.version = "0.1.2"
s.summary = "Runs Selenium tests from FitNesse"
s.description = <<-EOS
Rsel provides a Slim fixture for running Selenium tests, with
step methods written in Ruby.
EOS
- s.authors = ["Marcus French", "Dale Straw", "Eric Pierce"]
+ s.authors = ["Ken Brazier", "Marcus French", "Dale Straw", "Eric Pierce"]
s.email = "epierce@automation-excellence.com"
s.homepage = "http://github.com/a-e/rsel"
s.platform = Gem::Platform::RUBY

0 comments on commit b907956

Please sign in to comment.
Something went wrong with that request. Please try again.