Class SeleniumOnRails::TestBuilder
In: lib/selenium_on_rails/test_builder.rb
Parent: Object

Builds Selenium test table using a high-level Ruby interface. Normally invoked through SeleniumOnRails::RSelenese.

See SeleniumOnRails::TestBuilderActions for the available actions and SeleniumOnRails::TestBuilderAccessors for the available checks.

For more information on the commands supported by TestBuilder, see the Selenium Commands Documentation at release.openqa.org/selenium-core/nightly/reference.html.

Methods

Included Modules

SeleniumOnRails::TestBuilderActions SeleniumOnRails::TestBuilderAccessors SeleniumOnRails::TestBuilderUserActions SeleniumOnRails::TestBuilderUserAccessors

Public Class methods

Create a new TestBuilder for view.

[Source]

    # File lib/selenium_on_rails/test_builder.rb, line 47
47:   def initialize view
48:     @view = view
49:     @output = ''
50:     @xml = Builder::XmlMarkup.new :indent => 2, :target => @output
51:   end

Convert str to a Selenium command name.

[Source]

    # File lib/selenium_on_rails/test_builder.rb, line 36
36:   def self.selenize str
37:     str.camelize.gsub(/^[A-Z]/) {|s| s.downcase }
38:   end

Public Instance methods

Add a new test command using cmd, target and value.

[Source]

    # File lib/selenium_on_rails/test_builder.rb, line 62
62:   def command cmd, target=nil, value=nil
63:     @xml.tr do
64:       _tdata cmd
65:       _tdata target
66:       _tdata value
67:     end
68:   end

Same as command but add AndWait to the name of cmd.

[Source]

    # File lib/selenium_on_rails/test_builder.rb, line 73
73:   def command_and_wait cmd, target=nil, value=nil
74:     command_verbatim cmd.to_s + 'AndWait', target, value
75:   end
command_verbatim(cmd, target=nil, value=nil)

Alias for command

Prepends pattern with ‘exact:’ if it would be considered containing string-match pattern otherwise.

[Source]

    # File lib/selenium_on_rails/test_builder.rb, line 42
42:   def exactize pattern
43:     pattern.include?(':') ? "exact:#{pattern}" : pattern
44:   end

Re routes commands in the provided block to command_and_wait instead of command.

[Source]

    # File lib/selenium_on_rails/test_builder.rb, line 79
79:   def make_command_waiting
80:     self.class.send :alias_method, :command, :command_and_wait
81:     yield
82:     self.class.send :alias_method, :command, :command_verbatim 
83:   end

Add a new table of tests, and return the HTML.

[Source]

    # File lib/selenium_on_rails/test_builder.rb, line 54
54:   def table title
55:     @xml.table do
56:       @xml.tr do @xml.th(title, :colspan => 3) end
57:       yield self
58:     end
59:   end

Protected Instance methods

If arg is an array formats arg to a textual representation. Otherwise return unchanged.

[Source]

     # File lib/selenium_on_rails/test_builder.rb, line 95
 95:   def collection_arg arg
 96:     if arg.is_a? Array
 97:       arg.collect {|e| e.gsub(/[\\,]/) {|s| "\\#{s}" } }.join(',')
 98:     else
 99:       arg
100:     end
101:   end

If url is a string, return unchanged. Otherwise, pass it to ActionView#UrlHelper#url_for.

[Source]

    # File lib/selenium_on_rails/test_builder.rb, line 89
89:   def url_arg url
90:     if url.instance_of?(String) then url else exactize(@view.url_for(url)) end
91:   end

[Validate]