Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

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

0 comments on commit b907956

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