selenium_fury 1.0.3 → 1.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd83fba7efc074d50e44f358412f6f6eeecc0628
4
- data.tar.gz: aeb58034cad8ddf5956872a8eef08881ac3adc0e
3
+ metadata.gz: 71bbb0033e7a5217b2ff30149441d125c778262c
4
+ data.tar.gz: fba6daa554baa20fd1ca1b6f9f532eb25f6ac08a
5
5
  SHA512:
6
- metadata.gz: 7d01cef0793d4cab7eba865576d6afb3d90f8b172d206ee3a136fc129dcffbb176af500337488719df37dcd4e007d1898dfcbca87f301b823a93df0551b8173c
7
- data.tar.gz: a5999ac5c9cfd76830bb58d807bd3de53ab347d21a1a5a5d5b6d3e25835a08f7f00452cbf7f823e066c86714242f4d8d01d44e3d19edc15e9207f16e9089ea73
6
+ metadata.gz: 5c9e76b9f50b49aa0a4b305981229921176d9120251879efe81956b5e00ef68af8bac22be597d977d7a585d8362383ea3166977f9773526f60ad2a0742e5e0fe
7
+ data.tar.gz: b4aa5b73f72fe7f878ba9f7e7b8f94e91e6d5b447d96276732357e490fe77cd573bf99eced15fb517f96574a336d6a2b96d319b0c8a08a0f282f4392b010d942
@@ -4,24 +4,28 @@ module GenericElementHelpers
4
4
  @driver.find_element(location)
5
5
  end
6
6
 
7
+ def list
8
+ (1..number_matching).map { |i| self.class.new({css: location[:css]+":nth-of-type(#{i})"}, @driver) }
9
+ end
10
+
7
11
  def present?
8
12
  # Set implicit wait to zero so it doesn't wait that time each method call
9
13
  implicit_wait = driver.manage.timeouts.implicit_wait
10
14
  driver.manage.timeouts.implicit_wait = 0
11
- present = list.size > 0
15
+ present = number_matching > 0
12
16
  driver.manage.timeouts.implicit_wait = implicit_wait
13
17
  present
14
18
  end
15
19
 
20
+ def number_matching
21
+ @driver.find_elements(location).size
22
+ end
23
+
16
24
  # Raises error if not already present
17
25
  def visible?
18
26
  el.displayed?
19
27
  end
20
28
 
21
- def list
22
- @driver.find_elements(location)
23
- end
24
-
25
29
  def value
26
30
  el.attribute('value')
27
31
  end
@@ -30,6 +34,18 @@ module GenericElementHelpers
30
34
  @driver.action.move_to(el).perform
31
35
  end
32
36
 
37
+ def double_click
38
+ @driver.action.double_click(el).perform
39
+ end
40
+
41
+ def double_click!
42
+ el.click
43
+ rescue Exception => e
44
+ puts "Encountered #{e.class} trying to click element at #{self.location}"
45
+ ensure
46
+ el.click
47
+ end
48
+
33
49
  # Use any methods from WebDriverElement not present
34
50
  def method_missing method_sym, *args
35
51
  if el.respond_to?(method_sym)
@@ -86,7 +102,7 @@ module DropDownHelpers
86
102
  Selenium::WebDriver::Support::Select.new(el).first_selected_option.text
87
103
  end
88
104
 
89
- # how can be :text, :index, :value
105
+ # how can be :text, :index, :value
90
106
  def select_option(how=nil, what=nil)
91
107
  raise "Locator at #{location} can not be interacted with" unless visible?
92
108
  el.click if how.nil?
@@ -116,7 +132,7 @@ module SelectableElementHelpers
116
132
  el.selected?
117
133
  end
118
134
 
119
- # Raises error if not selectable
135
+ # Raises error if not selectable
120
136
  def select!
121
137
  raise "Locator at #{location} is not visible" unless visible?
122
138
  begin
@@ -138,7 +154,9 @@ module SelectableElementHelpers
138
154
  end
139
155
 
140
156
  # Overwrite in your project if desired
141
- def check_errors; end
157
+ def check_errors;
158
+ end
159
+
142
160
  def retry_select(exception)
143
161
  raise "Locator at #{location} can not be interacted with - Failed with #{exception}"
144
162
  end
@@ -1,3 +1,3 @@
1
1
  module SeleniumFury
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -59,9 +59,35 @@ describe PageObject do
59
59
  test_page.input_button_element.value.should == 'Click me'
60
60
  end
61
61
 
62
- it 'When there is more than one element with the provided locator, it should return an array of all of them' do
62
+
63
+ describe '#double_click' do
64
+ it 'should double-click the given element' do
65
+ status_before = test_page.input_doubleclick['readonly']
66
+ test_page.input_doubleclick.double_click
67
+ status_after = test_page.input_doubleclick['readonly']
68
+
69
+ status_after.should_not == status_before
70
+ end
71
+ end
72
+
73
+ describe '#double_click!' do
74
+ it 'should simply invoke click twice, ignoring any errors encountered on the initial click' do
75
+ status_before = test_page.input_doubleclick['readonly']
76
+ test_page.input_doubleclick.double_click!
77
+ status_after = test_page.input_doubleclick['readonly']
78
+
79
+ status_after.should == status_before # Because two #click()'s does not equal one #dblclick()
80
+ end
81
+ end
82
+
83
+ it 'When there is more than one element with the provided locator, it should return an array of GenericElements' do
63
84
  test_page.listings_element.list.should be_an Array
64
- test_page.listings_element.list[0].should be_an Selenium::WebDriver::Element
85
+ test_page.listings_element.list[0].should be_a SeleniumFury::SeleniumWebDriver::PageObjectComponents::GenericElement
86
+ end
87
+
88
+ it 'List element should provide correct information' do
89
+ test_page.listings_element.list[0].location.should == {css: 'li.listing:nth-of-type(1)'}
90
+ test_page.listings_element.list[0].text.should == 'Herpa'
65
91
  end
66
92
 
67
93
  describe Selenium::WebDriver::Element
@@ -171,13 +197,13 @@ describe PageObject do
171
197
  end
172
198
 
173
199
  it 'should throw not visible error if element to select is not visible and ! is specified' do
174
- expect {wait_element.not_visible.select!}.
175
- to raise_exception(RuntimeError, "Locator at #{wait_element.not_visible.location.to_s} is not visible")
200
+ expect { wait_element.not_visible.select! }.
201
+ to raise_exception(RuntimeError, "Locator at #{wait_element.not_visible.location.to_s} is not visible")
176
202
  end
177
203
 
178
204
  it 'should throw timeout error if element to select is not visible and ! is not specified' do
179
- expect {wait_element.not_visible.select}.
180
- to raise_exception(Selenium::WebDriver::Error::TimeOutError)
205
+ expect { wait_element.not_visible.select }.
206
+ to raise_exception(Selenium::WebDriver::Error::TimeOutError)
181
207
  end
182
208
  end
183
209
 
@@ -3,7 +3,7 @@ describe SeleniumFury::SeleniumWebDriver::PageGenerator do
3
3
  it "should find elements on the Test page" do
4
4
  launch_web_driver TEST_PAGE_URL
5
5
  result = generate(driver)
6
- result.should include 'found (15 elements)'
6
+ result.should include 'found (16 elements)'
7
7
  result.should include 'element :form, {:id => "form"}'
8
8
  end
9
9
  it "should return a TestPage page object" do
@@ -42,7 +42,7 @@ describe PageObject do
42
42
  launch_web_driver TEST_PAGE_URL
43
43
  test_page = TestPage.new(driver)
44
44
  test_page.class.elements.should_not be_nil
45
- test_page.class.elements.should have(39).elements
45
+ test_page.class.elements.should have(40).elements
46
46
  test_page.method(test_page.class.elements[0]).call.class.should == Selenium::WebDriver::Element
47
47
  end
48
48
 
@@ -63,6 +63,8 @@
63
63
  <label for="input_text">Text</label>
64
64
  <input id="input_text" type="text"/>
65
65
  <br/>
66
+ <label for="input_requires_double_click">This input requires double click</label>
67
+ <input id="input_requires_double_click" type="text" value="asdf" readonly="true" ondblclick="this.readOnly='';">
66
68
  <fieldset>
67
69
  <legend>Input test:</legend>
68
70
  <label for="input_message">Message Text:</label>
@@ -26,6 +26,7 @@ class TestPage < PageObject
26
26
  generic_element :fieldset_element, {css: 'fieldset'}
27
27
  generic_element :listings_element, {css: 'li.listing'}
28
28
  generic_element :not_visible_element, {id: 'not_visible'}
29
+ generic_element :input_doubleclick, {:id => 'input_requires_double_click'}
29
30
 
30
31
  checkbox_element :input_checkbox_element, {id: 'input_checkbox'}
31
32
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium_fury
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Sims
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-15 00:00:00.000000000 Z
11
+ date: 2013-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
- rubygems_version: 2.0.3
191
+ rubygems_version: 2.0.5
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Generate Selenium Page Objects