selenium-cucumber 3.1.4 → 3.1.5

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: e24fe4f35344bcbd0111758048ea49ee258d9f0c
4
- data.tar.gz: 11fc63be9966096e3f746cbc6a821878bfa7a91b
3
+ metadata.gz: 541c5f8d41f9c4111d99f41b80955e1ba616b006
4
+ data.tar.gz: 10db792d4ab59fc1f83fc317170f0f6b69bb0319
5
5
  SHA512:
6
- metadata.gz: 3a383bfc7c369c5fcb092cc2bf2846e4da91ded2ed410be12cad4db2d934efda701ae9b2e0e07bc266da3d55c678c7ef1cd62e8dd37b1b3345a038141eb0509f
7
- data.tar.gz: c64f2973bbd195ada16a036ad0850acb9081904755cd11f1508d0fcc0ca3eae05f509e3bb9eea917a638af9933a66893a25c4f598c0ffcc090fe8fb951cc6f52
6
+ metadata.gz: a3acdf1d3edb57727c085bd37d4b0b356c897ddc07e0861082884351f2fd54babb4307b4d45f882ff13d00c3b783d916524e0442b38aeed88ef83f04bdf29e9d
7
+ data.tar.gz: 6b9c6ae877704394938b9bcc725a4600c78ae755fadd3c941ed78be3081576bc584aba3626bd0f21751239f86b3fb8183dc5100b146032482650533fa8dd7288
@@ -29,6 +29,7 @@ To switch between windows use following steps :
29
29
  Then I switch to new window
30
30
  Then I switch to previous window
31
31
  Then I switch to window having title "(.*?)"
32
+ Then I switch to window having url "(.*?)"
32
33
  Then I close new window
33
34
  Then I switch to main window
34
35
 
@@ -476,6 +477,14 @@ To click on web element use following steps :
476
477
  Then I click on element having xpath "(.*?)"
477
478
  Then I click on element having css "(.*?)"
478
479
 
480
+ To click on web element with a particular text use the following steps :
481
+
482
+ Then I click on element having id "(.*?)" and text "(.*?)"
483
+ Then I click on element having name "(.*?)" and text "(.*?)"
484
+ Then I click on element having class "(.*?)" and text "(.*?)"
485
+ Then I click on element having xpath "(.*?)" and text "(.*?)"
486
+ Then I click on element having css "(.*?)" and text "(.*?)"
487
+
479
488
  To forcefully click on web element use following steps (if above steps do not work) :
480
489
 
481
490
  Then I forcefully click on element having id "(.*?)"
@@ -1,9 +1,12 @@
1
1
  require_relative 'methods/click_elements_methods'
2
2
 
3
- # click on web element
4
- When(/^I click on element having (.+) "(.*?)"$/) do |type, access_name|
3
+ When(/^I click on element having (id|name|class|xpath|css) "(.*?)"(?: and text "(.*?)")?$/) do |type, access_name, text|
5
4
  validate_locator type
6
- click(type, access_name)
5
+ if text
6
+ click_by_text(type, access_name, text)
7
+ else
8
+ click(type, access_name)
9
+ end
7
10
  end
8
11
 
9
12
  Then(/^I forcefully click on element having (.+) "(.*?)"$/) do |type, access_name|
@@ -1,10 +1,28 @@
1
1
  require_relative 'required_files'
2
2
 
3
-
4
3
  def click(access_type, access_name)
5
4
  $driver.find_element(:"#{access_type}" => "#{access_name}").click
6
5
  end
7
6
 
7
+ def click_by_text(access_type, access_name, text)
8
+ element_found = false
9
+ text_found = false
10
+ text_found = $driver.page_source.include? text
11
+ raise "Text '#{text}' was not found in the page source" unless text_found
12
+ # enter loop if the text is found
13
+ if text_found
14
+ elements = $driver.find_elements(:"#{access_type}" => "#{access_name}")
15
+ elements.each do |element|
16
+ if element.text == text
17
+ element_found = true
18
+ element.click
19
+ break
20
+ end
21
+ end
22
+ end
23
+ raise "Element not found having access type #{access_type}, access name #{access_name}, and text #{text}" unless element_found
24
+ end
25
+
8
26
  def click_forcefully(access_type, access_name)
9
27
  $driver.execute_script('arguments[0].click();', $driver.find_element(:"#{access_type}" => "#{access_name}"))
10
28
  end
@@ -133,6 +133,20 @@ def switch_to_window_by_title window_title
133
133
  raise "Window having title \"#{window_title}\" not found" if not window_found
134
134
  end
135
135
 
136
+ def switch_to_window_by_url window_url
137
+ $previous_window = $driver.window_handle
138
+ window_found = false
139
+ $driver.window_handles.each { |handle|
140
+ $driver.switch_to.window handle
141
+ # match absolute or relative
142
+ if $driver.current_url.include?(window_url)
143
+ window_found = true
144
+ break
145
+ end
146
+ }
147
+ raise "Window having url \"#{window_url}\" not found" if not window_found
148
+ end
149
+
136
150
  # Method to close new window
137
151
  def close_new_window
138
152
  $driver.close
@@ -50,6 +50,10 @@ Then(/^I switch to window having title "(.*?)"$/) do |window_title|
50
50
  switch_to_window_by_title window_title
51
51
  end
52
52
 
53
+ Then(/^I switch to window having url "(.*?)"$/) do |window_url|
54
+ switch_to_window_by_url window_url
55
+ end
56
+
53
57
  # step to close new window
54
58
  Then(/^I close new window$/) do
55
59
  close_new_window
@@ -1,5 +1,5 @@
1
1
  module Selenium
2
2
  module Cucumber
3
- VERSION = '3.1.4'
3
+ VERSION = '3.1.5'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.4
4
+ version: 3.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sameer Sawant
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-07 00:00:00.000000000 Z
11
+ date: 2016-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber