watir-or 0.0.4 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/watir-or.rb CHANGED
@@ -1,9 +1,5 @@
1
- Dir[File.join(File.dirname(__FILE__), "watir-or/converters") + "/*.rb"].each { |converter|
2
- require converter
3
- }
1
+ require File.join(File.dirname(__FILE__), 'watir-or/readers/xls')
2
+ require File.join(File.dirname(__FILE__), 'watir-or/readers/xml')
4
3
 
5
- Dir[File.join(File.dirname(__FILE__), "watir-or/readers") + "/*.rb"].each { |reader|
6
- require reader
7
- }
8
- require 'watir-or/element'
9
- require 'watir-or/repository'
4
+ require File.join(File.dirname(__FILE__), 'watir-or/element')
5
+ require File.join(File.dirname(__FILE__), 'watir-or/repository')
@@ -1,71 +1,65 @@
1
1
  module ObjectRepository
2
2
  class RepositoryElement
3
- attr_reader :rep_id, :type, :description
3
+ attr_reader :name
4
4
 
5
- def initialize(rep_id, type, hows, whats, description, repository)
6
- @rep_id = rep_id.dup
7
- @description = description #.dup
8
- @type = type.dup
9
- @hows, @whats = hows.dup, whats.dup
5
+ def initialize(name, repository, &block)
6
+ @name = name
10
7
  @repository = repository
8
+ instance_eval &block
11
9
  end
12
10
 
13
11
  def inspect
14
- "Element #{@rep_id.inspect}:\n\thows: #{@hows.inspect}\n\twhats: #{@whats.inspect}\n\tdescription: #{@description.inspect}\n"
12
+ "Element #{@name.inspect}"
15
13
  end
16
14
 
17
15
  def ==(other)
18
- @rep_id == other.rep_id && @type == other.type && @description == other.description
16
+ @name == other.name
19
17
  end
20
18
  end
21
19
 
22
20
  class WatirElement < RepositoryElement
23
- include WatirObjectBuilder
24
- attr_reader :watir_obj, :locator
25
-
26
- def initialize(id, type, hows, whats, description, repository)
27
- super(id, type, hows, whats, description, repository)
28
- transform_whats!
29
- @locator = Hash[*@hows.zip(@whats).flatten]
21
+ def locate(&block)
22
+ if block_given?
23
+ @locate_block = block
24
+ end
30
25
  end
31
26
 
32
27
  def method_missing(meth_name, *args, &block)
33
- @watir_obj ||= WatirObjectBuilder.build_watir_obj(@repository, self)
34
- if @watir_obj.respond_to?(meth_name) || meth_name.to_s.include?("_no_wait")
35
- @watir_obj.send(meth_name, *args, &block)
36
- else
37
- super
38
- end
28
+ @locate_block.call(@repository).send(meth_name, *args, &block)
39
29
  end
40
30
 
41
31
  def present?
42
32
  method_missing(:present?)
43
33
  end
44
-
45
- private
46
-
47
- def transform_whats!
48
- @hows.each_with_index do |how, index|
49
- if how == :index
50
- @whats[index] = @whats[index].to_i
51
- elsif @whats[index] =~ /^\/(.*)\/$/ && how != :xpath
52
- @whats[index] = Regexp.new($1)
53
- end
54
- end
55
- end
56
34
  end
57
35
 
58
36
  class CustomElement < RepositoryElement
59
37
  def initialize(*args)
60
- super(*args)
61
38
  @attributes = {}
62
- @hows.each_with_index do |how, index|
63
- @attributes[how] = @repository.get_by_rep_id(@whats[index])
39
+ super(*args)
40
+ end
41
+
42
+ def field(name, field_name = nil, &block)
43
+ if block_given?
44
+ @attributes[name] = block
45
+ return
46
+ end
47
+
48
+ if field_name
49
+ @attributes[name] = field_name
50
+ else
51
+ get_field(name)
64
52
  end
65
53
  end
66
54
 
67
- def field(name)
68
- @attributes[name]
55
+ private
56
+
57
+ def get_field(name)
58
+ if @attributes[name].is_a?(String)
59
+ @repository.get(@attributes[name])
60
+ else
61
+ @attributes[name].call(@repository)
62
+ end
69
63
  end
70
64
  end
71
- end
65
+ end
@@ -19,27 +19,21 @@ module ObjectRepository
19
19
 
20
20
  def self.read_worksheet(worksheet, &block)
21
21
  rows_count = worksheet.row_count
22
- hows = Array.new
23
- whats = Array.new
24
- rep_id = nil
25
- description = nil
26
- type = nil
27
22
  worksheet.each(1) { |row| # each(1) exclude header
28
- unless row[0].nil?
29
- hows.clear
30
- whats.clear
31
- rep_id = row[0]
32
- type = row[1]
33
- description = row[4]
34
- end
35
- hows << row[2]
36
- whats << row[3]
37
23
  if (!worksheet.row(row.idx + 1)[0].nil? || row.idx + 1 >= rows_count )
38
- yield rep_id, type, hows.map { |el| el.to_sym }, whats, description
24
+ name = row[0]
25
+ type = nil
26
+ locate_block = if row[2].nil?
27
+ Proc.new { locate { |repository| eval(row[1]) } }
28
+ else
29
+ type = eval(row[2])
30
+ Proc.new { |repository| eval(row[1]) }
31
+ end
32
+ yield name, type, locate_block
39
33
  end
40
34
  }
41
35
  end
42
36
  end
43
37
  end
44
38
  end
45
-
39
+
@@ -5,19 +5,19 @@ module ObjectRepository
5
5
 
6
6
  def self.read(file, options = nil, &block)
7
7
  doc = Nokogiri::XML(File.read(file), nil, 'UTF-8', Nokogiri::XML::ParseOptions::NOBLANKS)
8
- doc.root.xpath("//object").each { |node|
9
- hows = node.search("./how").children
10
- whats = hows.map { |h| h.content }
11
- #Add parent
12
- hows = hows.map { |h| h.name.to_sym }
13
- if node.parent != doc.root
14
- hows << :parent
15
- whats << node.parent['id']
16
- end
17
-
18
- yield node['id'], node['type'], hows, whats, node.search('./description').first.content
19
- }
8
+ doc.root.xpath("//object").each do |node|
9
+ name = node['name']
10
+ type = nil
11
+ locate = node.search('./locate').first.content
12
+ locate_block = if node['type'].nil?
13
+ Proc.new { locate { |repository| eval(locate) } }
14
+ else
15
+ type = eval(node['type'])
16
+ Proc.new { |repository| eval(locate) }
17
+ end
18
+ yield name, type, locate_block
19
+ end
20
20
  end
21
21
  end
22
22
  end
23
- end
23
+ end
@@ -5,7 +5,7 @@ module ObjectRepository
5
5
 
6
6
  def initialize(file, browser, options = nil)
7
7
  @file = file
8
- @elements = Array.new
8
+ @elements = []
9
9
  @browser = browser
10
10
  @type = File.extname(@file).delete('.')
11
11
  fill_elements(options)
@@ -15,19 +15,12 @@ module ObjectRepository
15
15
  @elements.each { |el| yield el }
16
16
  end
17
17
 
18
- def method_missing(meth_name, what, &block)
19
- element = case meth_name.to_s
20
- when /^get_by_(.*)/
21
- find { |el| el.instance_variable_get("@#{$1.to_sym}") == what }
22
- when "get"
23
- find { |el| el.rep_id == what || el.description == what }
24
- else
25
- super
26
- end
27
- raise "Couldn't find repository element with #{what.inspect}" if element.nil?
18
+ def get(name)
19
+ element = find { |el| el.name == name }
20
+ raise "Couldn't find repository element with #{name.inspect}" if element.nil?
28
21
  return element
29
22
  end
30
-
23
+
31
24
  def inspect
32
25
  @elements.inspect
33
26
  end
@@ -35,19 +28,30 @@ module ObjectRepository
35
28
  private
36
29
 
37
30
  def fill_elements(options)
38
- eval("ObjectRepository::Reader::" + @type.upcase).read(@file, options) do |rep_id, type, hows, whats, description|
39
- unless @elements.find { |el| el.rep_id == rep_id }
40
- @elements << if type[0..0] =~ /[A-Z]/
41
- eval("#{type}").new(rep_id, type, hows, whats, description, self)
42
- else
43
- WatirElement.new(rep_id, type, hows, whats, description, self)
44
- end
45
- else
46
- raise "Duplicating of id: #{rep_id.inspect}"
47
- end
31
+ reader_class = case @type.downcase
32
+ when 'xml'
33
+ ObjectRepository::Reader::XML
34
+ when 'xls'
35
+ ObjectRepository::Reader::XLS
36
+ when 'rb'
37
+ instance_eval(File.read(file), file)
38
+ return
39
+ else
40
+ raise "Unknown type #{@type.inspect} of repository"
41
+ end
42
+
43
+ reader_class.read(@file, options) do |name, type, block|
44
+ element(name, type, &block)
45
+ end
46
+ end
47
+
48
+ def element(name, type = nil, &block)
49
+ raise "Duplicating of name: #{name.inspect}" if @elements.find { |el| el.name == name }
50
+ @elements << unless type
51
+ WatirElement.new(name, self, &block)
52
+ else
53
+ type.new(name, self, &block)
48
54
  end
49
- rescue NameError
50
- raise "Unknown type #{@type.inspect} of repository"
51
55
  end
52
56
  end
53
- end
57
+ end
@@ -1,7 +1,6 @@
1
- class BrowserStub
1
+ class BrowserMock
2
2
  def method_missing(meth_name, *args, &block)
3
3
  Control.new
4
- # return "%s(%s)" % [meth_name, args.first.inspect.gsub(/(^\{|\}$)/, "")]
5
4
  end
6
5
  end
7
6
 
@@ -9,4 +8,4 @@ class Control
9
8
  def method_missing(meth_name, *args, &block)
10
9
  Control.new
11
10
  end
12
- end
11
+ end
@@ -1,21 +1,19 @@
1
1
  require 'lib/watir-or'
2
- require 'spec/browser_stub'
3
2
  require 'spec/spec_helper'
4
3
  TEST_FILE = "spec/test.xls"
5
4
 
6
5
  describe "CustomElement" do
7
6
  before(:all) do
8
- @browser_stub = BrowserStub.new
7
+ @browser_stub = BrowserMock.new
9
8
  @repository = ObjectRepository::Repository.new(TEST_FILE, @browser_stub)
10
9
  end
11
10
 
12
11
  it "should return MyCustomElement object" do
13
- @repository.get("custom element").should be_a(MyCustomElement)
12
+ @repository.get("Custom Element").should be_a(MyCustomElement)
14
13
  end
15
14
 
16
15
  it "should return field of MyCustomElement object" do
17
- attr1 = ObjectRepository::RepositoryElement.new("one attribute", "text_field", [:name],
18
- ["test"], "Element with one attribute", @repository)
19
- @repository.get("custom element").field(:attr1).should == attr1
16
+ attr1 = ObjectRepository::WatirElement.new("Element with one attribute", @repository) { |block| block }
17
+ @repository.get("Custom Element").field(:attr1).should == attr1
20
18
  end
21
19
  end
@@ -1,36 +1,18 @@
1
1
  require 'lib/watir-or.rb'
2
- require 'spec/browser_stub'
3
2
  require 'spec/spec_helper'
4
3
 
5
4
  describe "Search of elements" do
6
5
  before(:all) do
7
- @browser_stub = BrowserStub.new
6
+ @browser_stub = BrowserMock.new
8
7
  @repository = ObjectRepository::Repository.new("spec/test.xls", @browser_stub)
9
- @element = ObjectRepository::RepositoryElement.new("many attributes", "select_list", [:text, :index],
10
- ["test text", 1], "Element with many attributes", @repository)
8
+ @element = ObjectRepository::WatirElement.new("Element with many attributes", @repository) { }
11
9
  end
12
10
 
13
- context "find element by id or description if argument is" do
14
- it "id" do
15
- @repository.get("many attributes").should == @element
16
- end
17
-
18
- it "description" do
19
- @repository.get("Element with many attributes").should == @element
20
- end
21
- end
22
-
23
- context "find by" do
24
- it "id" do
25
- @repository.get_by_rep_id("many attributes").should == @element
26
- end
27
-
28
- it "description" do
29
- @repository.get_by_description("Element with many attributes").should == @element
30
- end
11
+ it "find by name" do
12
+ @repository.get("Element with many attributes").should == @element
31
13
  end
32
14
 
33
15
  it "should raise exception when element wasn't found" do
34
16
  lambda{@repository.get("fake element")}.should raise_error
35
17
  end
36
- end
18
+ end
@@ -0,0 +1,18 @@
1
+ require 'lib/watir-or.rb'
2
+ require 'spec/spec_helper'
3
+
4
+ describe "Read xls-repository" do
5
+ before(:all) do
6
+ @repository = ObjectRepository::Repository.new("spec/test.rb", BrowserMock.new)
7
+ end
8
+
9
+ it "get watir element" do
10
+ one = ObjectRepository::WatirElement.new("Watir Element", @repository) { }
11
+ @repository.get("Watir Element").should == one
12
+ end
13
+
14
+ it "get custom element" do
15
+ custom = MyCustomElement.new("Custom Element", @repository) { }
16
+ @repository.get("Custom Element").should == custom
17
+ end
18
+ end
@@ -2,58 +2,47 @@ require 'lib/watir-or.rb'
2
2
  require 'spec/spec_helper'
3
3
 
4
4
  describe "Read xls-repository" do
5
- context "Read first worksheet" do
5
+ context "On first worksheet" do
6
6
  before(:all) do
7
- @repository = ObjectRepository::Repository.new("spec/test.xls", BrowserStub.new)
7
+ @repository = ObjectRepository::Repository.new("spec/test.xls", BrowserMock.new)
8
8
  end
9
9
 
10
- it "element with one attribute was readed" do
11
- one = ObjectRepository::RepositoryElement.new("one attribute", "text_field", [:name],
12
- ["test"], "Element with one attribute", @repository)
13
- @repository.get("one attribute").should == one
10
+ it "get watir element" do
11
+ one = ObjectRepository::WatirElement.new("Element with many attributes", @repository) { }
12
+ @repository.get("Element with many attributes").should == one
14
13
  end
15
14
 
16
- it "element with many attribute was readed" do
17
- many = ObjectRepository::RepositoryElement.new("many attributes", "select_list", [:text, :index],
18
- ["test text", 1], "Element with many attributes", @repository)
19
- @repository.get("many attributes").should == many
20
- end
21
-
22
- it "last element with many attribute was readed" do
23
- last_many = ObjectRepository::RepositoryElement.new("last element with many attributes", "image",
24
- [:name, :src], ["xxx", "path"], "Last element with many attributes", @repository)
25
- @repository.get("last element with many attributes").should == last_many
15
+ it "get custom element" do
16
+ custom = MyCustomElement.new("Custom Element", @repository) { }
17
+ @repository.get("Custom Element").should == custom
26
18
  end
27
19
  end
28
20
 
29
21
  context "Read special worksheet" do
30
22
  before(:all) do
31
- @repository = ObjectRepository::Repository.new("spec/test.xls", BrowserStub.new, :worksheet => "special worksheet")
23
+ @repository = ObjectRepository::Repository.new("spec/test.xls", BrowserMock.new, :worksheet => "special worksheet")
32
24
  end
33
25
 
34
26
  it "should read element on special workheet" do
35
- first = ObjectRepository::RepositoryElement.new("first element", "text_field",
36
- [:name], ["awesome"], "First element on special worksheet", @repository)
37
- @repository.get("first element").should == first
27
+ first = ObjectRepository::WatirElement.new("First element on special worksheet", @repository) { }
28
+ @repository.get("First element on special worksheet").should == first
38
29
  end
39
30
  end
40
31
 
41
32
  context "Read all worksheets" do
42
33
  before(:all) do
43
- @repository = ObjectRepository::Repository.new("spec/test.xls", BrowserStub.new, :worksheet => :all)
34
+ @repository = ObjectRepository::Repository.new("spec/test.xls", BrowserMock.new, :worksheet => :all)
44
35
  end
45
36
 
46
37
  it "should read all elements on all workheets" do
47
- on_first_worksheet = ObjectRepository::RepositoryElement.new("one attribute", "text_field", [:name],
48
- ["test"], "Element with one attribute", @repository)
49
- on_special_worksheet = ObjectRepository::RepositoryElement.new("first element", "text_field",
50
- [:name], ["awesome"], "First element on special worksheet", @repository)
51
- @repository.get("one attribute").should == on_first_worksheet
52
- @repository.get("first element").should == on_special_worksheet
38
+ on_first_worksheet = ObjectRepository::WatirElement.new("Element with one attribute", @repository) { }
39
+ on_special_worksheet = ObjectRepository::WatirElement.new("First element on special worksheet", @repository) { }
40
+ @repository.get("Element with one attribute").should == on_first_worksheet
41
+ @repository.get("First element on special worksheet").should == on_special_worksheet
53
42
  end
54
43
  end
55
44
 
56
45
  it "duplicating of id" do
57
- lambda { ObjectRepository::Repository.new("spec/test_duplicating_id.xls", BrowserStub.new) }.should raise_error
46
+ lambda { ObjectRepository::Repository.new("spec/test_duplicating_id.xls", BrowserMock.new) }.should raise_error
58
47
  end
59
- end
48
+ end
@@ -3,24 +3,16 @@ require 'spec_helper'
3
3
 
4
4
  describe "Read xml-repository" do
5
5
  before(:all) do
6
- @repository = ObjectRepository::Repository.new("spec/test.xml", BrowserStub.new)
6
+ @repository = ObjectRepository::Repository.new("spec/test.xml", BrowserMock.new)
7
7
  end
8
8
 
9
9
  it "element with one attribute was readed" do
10
- one = ObjectRepository::RepositoryElement.new("one attribute", "text_field", [:name],
11
- ["test"], "Element with one attribute", @repository)
12
- @repository.get("one attribute").should == one
10
+ one = ObjectRepository::WatirElement.new("Element with one attribute", @repository) { }
11
+ @repository.get("Element with one attribute").should == one
13
12
  end
14
13
 
15
- it "element with many attribute was readed" do
16
- many = ObjectRepository::RepositoryElement.new("many attributes", "select_list", [:text, :index],
17
- ["test text", 1], "Element with many attributes", @repository)
18
- @repository.get("many attributes").should == many
14
+ it "custom element" do
15
+ custom = MyCustomElement.new("Custom Element", @repository) { }
16
+ @repository.get("Custom Element").should == custom
19
17
  end
20
-
21
- it "child element was readed" do
22
- child = ObjectRepository::RepositoryElement.new("with parent", "div", [:index, :parent],
23
- [3, "parent element"], "Element with parent", @repository)
24
- @repository.get("with parent").should == child
25
- end
26
- end
18
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'browser_stub'
1
+ require 'browser_mock'
2
2
 
3
3
  class MyCustomElement < ObjectRepository::CustomElement
4
- end
4
+ end
data/spec/test.rb ADDED
@@ -0,0 +1,9 @@
1
+ element "Watir Element" do
2
+ locate do |repository|
3
+ repository.browser.text_field(:name => "test")
4
+ end
5
+ end
6
+
7
+ element "Custom Element", MyCustomElement do
8
+ field :attr1, "Watir Element"
9
+ end
data/spec/test.xls CHANGED
Binary file
data/spec/test.xml CHANGED
@@ -1,35 +1,11 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <repository>
3
- <object type="text_field" id="one attribute">
4
- <how>
5
- <name>test</name>
6
- </how>
7
- <description>Element with one attribute</description>
3
+ <object name="Element with one attribute">
4
+ <locate>reposiroty.browser.text_field(:name => "name")</locate>
8
5
  </object>
9
- <object type="select_list" id="many attributes">
10
- <how>
11
- <text>test text</text>
12
- <index>1</index>
13
- </how>
14
- <description>Element with many attributes</description>
6
+ <object type="MyCustomElement" name="Custom Element">
7
+ <locate>
8
+ field :attr1, "Element with one attribute"
9
+ </locate>
15
10
  </object>
16
- <object type="div" id="parent element">
17
- <how>
18
- <index>1</index>
19
- </how>
20
- <description>Parent element</description>
21
- <object type="div" id="with parent">
22
- <how>
23
- <index>3</index>
24
- </how>
25
- <description>Element with parent</description>
26
- </object>
27
- </object>
28
- <object type="MyCustomElement" id="custom element">
29
- <how>
30
- <attr1>one attribute</attr1>
31
- <attr2>many attributes</attr2>
32
- </how>
33
- <description>Custom Element</description>
34
- </object>
35
- </repository>
11
+ </repository>
Binary file
metadata CHANGED
@@ -3,10 +3,10 @@ name: watir-or
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
+ - 1
6
7
  - 0
7
8
  - 0
8
- - 4
9
- version: 0.0.4
9
+ version: 1.0.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ivan Kabluchkov
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-06-16 00:00:00 +04:00
17
+ date: 2011-06-29 00:00:00 +04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -59,25 +59,25 @@ extra_rdoc_files:
59
59
  files:
60
60
  - README
61
61
  - Rakefile
62
- - lib/watir-or/converters/element_converter.rb
63
62
  - lib/watir-or/element.rb
64
63
  - lib/watir-or/readers/xls.rb
65
64
  - lib/watir-or/readers/xml.rb
66
65
  - lib/watir-or/repository.rb
67
66
  - lib/watir-or.rb
68
- - spec/browser_stub.rb
67
+ - spec/browser_mock.rb
69
68
  - spec/custom_elements_spec.rb
70
69
  - spec/find_elements_spec.rb
70
+ - spec/read_rb_spec.rb
71
71
  - spec/read_xls_spec.rb
72
72
  - spec/read_xml_spec.rb
73
73
  - spec/spec.opts
74
74
  - spec/spec_helper.rb
75
+ - spec/test.rb
75
76
  - spec/test.xls
76
77
  - spec/test.xml
77
78
  - spec/test_duplicating_id.xls
78
- - spec/watir_builder_spec.rb
79
79
  has_rdoc: true
80
- homepage:
80
+ homepage: https://github.com/lfidnl/watir-or
81
81
  licenses: []
82
82
 
83
83
  post_install_message:
@@ -111,6 +111,6 @@ summary: Object Repository for Watir
111
111
  test_files:
112
112
  - spec/custom_elements_spec.rb
113
113
  - spec/find_elements_spec.rb
114
+ - spec/read_rb_spec.rb
114
115
  - spec/read_xls_spec.rb
115
116
  - spec/read_xml_spec.rb
116
- - spec/watir_builder_spec.rb
@@ -1,27 +0,0 @@
1
- module ObjectRepository
2
- module WatirObjectBuilder
3
- def self.build_watir_obj(repository, rep_element)
4
- eval("repository.browser.#{build_element(rep_element, repository)}")
5
- end
6
-
7
- def self.build_element(rep_element, repository)
8
- parent = ""
9
- unless rep_element.locator[:parent].nil?
10
- parent = build_element(repository.find { |el| el.rep_id == rep_element.locator[:parent] }, repository) + "."
11
- end
12
- locator = rep_element.locator.dup
13
- locator.delete(:parent)
14
- parent << "%s(%s)" % [rep_element.type, build_locator(locator)]
15
- end
16
-
17
- #Method need for separate frame(:name => "foo") and frame(:name, "foo").
18
- #Because frame with multiply conditions doesn't work
19
- def self.build_locator(locator)
20
- if locator.length > 1
21
- locator.inspect.gsub(/(^\{|\}$)/, "")
22
- else
23
- ":%s,%s" % [locator.keys.first, locator[locator.keys.first].inspect]
24
- end
25
- end
26
- end
27
- end
@@ -1,36 +0,0 @@
1
- require 'lib/watir-or.rb'
2
- require 'spec/browser_stub'
3
- require 'spec/spec_helper'
4
-
5
- describe "WatirObjectBuilder" do
6
- before(:all) do
7
- @browser_stub = BrowserStub.new
8
- @repository = ObjectRepository::Repository.new("spec/test.xls", @browser_stub)
9
- end
10
-
11
- it "build watir object properly" do
12
- element = @repository.get('many attributes')
13
- built = ObjectRepository::WatirObjectBuilder.build_element(element, @repository)
14
- built.should == 'select_list(:index=>1, :text=>"test text")'
15
- end
16
-
17
- it "build element with regexp" do
18
- element = @repository.get('with regexp what')
19
- built = ObjectRepository::WatirObjectBuilder.build_element(element, @repository)
20
- built.should == 'text_field(:text,/regexp/)'
21
- end
22
-
23
- context "hierarchy" do
24
- it "watir object which has one parent" do
25
- element = @repository.get('with parent')
26
- built = ObjectRepository::WatirObjectBuilder.build_element(element, @repository)
27
- built.should == 'div(:index,1).div(:index,3)'
28
- end
29
-
30
- it "2 level" do
31
- element = @repository.get('2 level hierarchy')
32
- built = ObjectRepository::WatirObjectBuilder.build_element(element, @repository)
33
- built.should == 'div(:index,1).div(:index,3).div(:index,5)'
34
- end
35
- end
36
- end