wist 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 284bbc9a713b2d5eec513fc03c059e4e27ad4d6d
4
- data.tar.gz: 5364a261212cdc4d4f6697137f0ea4dad60098b9
3
+ metadata.gz: 9c192acd0d89e49e0336d0225fc15b66c32ab82a
4
+ data.tar.gz: a84a7e169f92e5d61c4dd912d4d7dc675543f2f7
5
5
  SHA512:
6
- metadata.gz: ca50012cc0a995114862e3bda38c2f8608d59d2d1a45c245f4fd04f2a2e4aff7c7cece77d9d9bf2d2fbc371f2bd9380f84f88ae79b4e98ad81b039882b12d803
7
- data.tar.gz: 01f5213e9eadb081c3ed4d84d4ea88a6b2691bda2725e7a18387381cc68b6b33e286ccad119bcd51d0c393d48a416407ca15cce1a41ae14aafaf88412129bb34
6
+ metadata.gz: 62ce97f8ea34acc5bf4eb314f49e373a6faeba1003eb910be607aab4d275a591f7a5ee78e9758491646c7bc2ec09ac520bcc5e12bf09a75458c8600ab61ab617
7
+ data.tar.gz: 28d90462182499176f036e5c7d5a80c1a497cc467a8d3a852f1a5049ddf1404f6719ebdebfeaaa97f7ebf44621281c4aa808d3fa7a93e9ada28ef84b8efe9674
data/lib/wist.rb CHANGED
@@ -15,8 +15,8 @@ module Wist
15
15
  end
16
16
  end
17
17
 
18
- def wait_until
19
- Selenium::WebDriver::Wait.new(timeout: Capybara.default_wait_time).until do
18
+ def wait_until(timeout: Capybara.default_wait_time)
19
+ Selenium::WebDriver::Wait.new(timeout: timeout).until do
20
20
  begin
21
21
  yield
22
22
  rescue
@@ -113,9 +113,9 @@ module Wist
113
113
  end
114
114
 
115
115
  %w(first all).each do |finder|
116
- define_method(:"#{finder}_with_wait") do |selector|
117
- has_css?(selector)
118
- page.send(finder.to_sym, selector)
116
+ define_method(:"#{finder}_with_wait") do |*args|
117
+ has_css?(*args)
118
+ page.send(finder.to_sym, *args)
119
119
  end
120
120
  end
121
121
 
@@ -144,4 +144,11 @@ module Wist
144
144
  def parent(el)
145
145
  el.first(:xpath, './/..')
146
146
  end
147
+
148
+ def click_by_text(selector, text, text_include: true, downcase: true)
149
+ all_with_wait(selector, visible: true).find do |el|
150
+ el_text = downcase ? el.text.downcase : el.text
151
+ text_include ? el_text.include?(text) : el_text == text
152
+ end.click
153
+ end
147
154
  end
data/test/test.js CHANGED
@@ -42,3 +42,7 @@ $('#finder_with_wait').click(function () {
42
42
  $this.addClass('done');
43
43
  }, 1000);
44
44
  });
45
+
46
+ $('#click_by_text').click(function () {
47
+ $(this).text('clicked');
48
+ });
data/test/test0.html CHANGED
@@ -24,6 +24,8 @@
24
24
 
25
25
  <input id='test_set_input_and_press_enter' type='text' />
26
26
 
27
+ <button id='click_by_text'>click by text</button>
28
+
27
29
  <div id='test_scroll_to'></div>
28
30
 
29
31
  <button id='finder_with_wait'>foo</button>
@@ -113,11 +113,11 @@ class WistTest < CapybaraTestCase
113
113
 
114
114
  def test_finder_with_wait
115
115
  click('#finder_with_wait')
116
- assert_equal('finder_with_wait', first_with_wait('.done')[:id])
116
+ assert_equal('finder_with_wait', first_with_wait('.done', visible: true)[:id])
117
117
 
118
118
  refresh
119
119
  click('#finder_with_wait')
120
- assert_equal('finder_with_wait', all_with_wait('.done')[0][:id])
120
+ assert_equal('finder_with_wait', all_with_wait('.done', visible: true)[0][:id])
121
121
  end
122
122
 
123
123
  def test_visit_with_retries
@@ -142,4 +142,9 @@ class WistTest < CapybaraTestCase
142
142
  def test_parent
143
143
  assert_text('parent', parent(find('#test_parent', visible: false)))
144
144
  end
145
+
146
+ def test_click_by_text
147
+ click_by_text('button', 'click by text')
148
+ assert_text('clicked', find('#click_by_text'))
149
+ end
145
150
  end
data/wist.gemspec CHANGED
@@ -1,10 +1,11 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'wist'
3
- gem.version = '0.1.1'
3
+ gem.version = '0.1.2'
4
4
  gem.summary = 'capybara helpers'
5
5
  gem.author = 'Lihan Li'
6
6
  gem.email = 'frankieteardrop@gmail.com'
7
7
  gem.homepage = 'http://github.com/lihanli/wist'
8
+ gem.license = 'MIT'
8
9
 
9
10
  gem.add_dependency 'capybara'
10
11
  gem.add_dependency 'selenium-webdriver'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lihan Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-18 00:00:00.000000000 Z
11
+ date: 2013-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -61,7 +61,8 @@ files:
61
61
  - test/tests/wist_test.rb
62
62
  - wist.gemspec
63
63
  homepage: http://github.com/lihanli/wist
64
- licenses: []
64
+ licenses:
65
+ - MIT
65
66
  metadata: {}
66
67
  post_install_message:
67
68
  rdoc_options: []