# Class: SeleniumOnRails::TestBuilder

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

command command_and_wait command_verbatim exactize make_command_waiting new selenize table

### Included Modules

SeleniumOnRails::TestBuilderActions SeleniumOnRails::TestBuilderAccessors

### Public Class methods

new(view)

Create a new TestBuilder for view.

[Source]

        # File lib/selenium_on_rails/test_builder.rb, line 26
    26:   def initialize view
    27:     @view = view
    28:     @output = ''
    29:     @xml = Builder::XmlMarkup.new :indent => 2, :target => @output
    30:   end

selenize(str)

Convert str to a Selenium command name.

[Source]

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

### Public Instance methods

command(cmd, target=nil, value=nil)

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

[Source]

        # File lib/selenium_on_rails/test_builder.rb, line 41
    41:   def command cmd, target=nil, value=nil
    42:     @xml.tr do
    43:       _tdata cmd
    44:       _tdata target
    45:       _tdata value
    46:     end
    47:   end

command_and_wait(cmd, target=nil, value=nil)

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

[Source]

        # File lib/selenium_on_rails/test_builder.rb, line 52
    52:   def command_and_wait cmd, target=nil, value=nil
    53:     command_verbatim cmd.to_s + 'AndWait', target, value
    54:   end

command_verbatim(cmd, target=nil, value=nil)

Alias for command

exactize(pattern)

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

[Source]

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

make_command_waiting() {|| ...}

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

[Source]

        # File lib/selenium_on_rails/test_builder.rb, line 58
    58:   def make_command_waiting
    59:     self.class.send :alias_method, :command, :command_and_wait
    60:     yield
    61:     self.class.send :alias_method, :command, :command_verbatim
    62:   end

table(title) {|self| ...}

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

[Source]

        # File lib/selenium_on_rails/test_builder.rb, line 33
    33:   def table title
    34:     @xml.table do
    35:       @xml.tr do @xml.th(title, :colspan => 3) end
    36:       yield self
    37:     end
    38:   end

[Validate]