gridium 0.1.16 → 0.1.17

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gridium/version.rb +1 -1
  3. data/lib/page.rb +23 -6
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf7d9d1bcac31e36fda6bef78eaaaf9f833886cd
4
- data.tar.gz: 9045c4caafa09133659f4ec8825dcc264436928e
3
+ metadata.gz: 0243e90dc04686fa9dd3200eee663b9238dc88bc
4
+ data.tar.gz: 5bd35b0d358ced862c13feabef4772a73924460a
5
5
  SHA512:
6
- metadata.gz: d85c4eafeca504f387795108e992e4f8d44c9605f3f03729c48c9c3dc49c54fd1a5641ac38d322d2b8f4f0195e69bb8dd05b234b62c8216fb52494fcd6927385
7
- data.tar.gz: f4fd979c9da4b62c497c8a001451bf1a6dc9c8ba8ab205f4bfd615ad74432fd74ccd4f97fbc56ef5bdf223aea38554e2a3287712a412a9e20b93324f61656aed
6
+ metadata.gz: 72aa492030136743d2807f645abe6a751448f1cad8bdcab669742f0a8314644de396df415482047c8a86124381c376479eb889ec6233f2319f274980d5b00fff
7
+ data.tar.gz: be03d5a63d31c63608613caab100a584a4dd6b5db152988e49f685b1c682a5a37f6b42b3be518d583acaec756e0e62ffda377aa486f336010f58191a9aae2361
@@ -1,3 +1,3 @@
1
1
  module Gridium
2
- VERSION = "0.1.16"
2
+ VERSION = "0.1.17"
3
3
  end
data/lib/page.rb CHANGED
@@ -103,19 +103,36 @@ module Gridium
103
103
  Driver.driver.find_elements(by, locator).first
104
104
  end
105
105
 
106
- def click_link(link_text)
107
- Element.new("Clicking #{link_text} Link", :link_text, link_text).click
106
+ def click_on(text)
107
+ Element.new("Clicking #{text}", :xpath, "//*[text()='#{text}')]").click
108
108
  end
109
109
 
110
- def click_button(button_name)
110
+ # Click the link on the page
111
+ # @param [String] link_text - Text of the link to click
112
+ # @param [Integer] link_index (optional) - With multiple links on the page with the same name, click on the specified link index
113
+ def click_link(link_text, link_index: nil)
114
+ if link_index
115
+ Element.new("Clicking #{link_text} Link (#{link_index})", :xpath, "(//a[contains(., '#{link_text}')])[#{link_index}]").click
116
+ else
117
+ Element.new("Clicking #{link_text} Link", :xpath, "//a[contains(., '#{link_text}')]").click
118
+ end
119
+ end
120
+
121
+ # Click the button on the page
122
+ # @param [String] link_text - Text of the link to click
123
+ # @param [Integer] link_index - With multiple links on the page with the same name, click on the specified link index (Defaults to first link found)
124
+ def click_button(button_name, button_index: nil)
111
125
  #The button maybe a link that looks like a button - we want to handle both
112
- button = Element.new("A #{button_name} button", :xpath, "//button[contains(., '#{button_name}')]")
126
+ if button_index
127
+ button = Element.new("Clicking #{button_name} button (#{button_index})", :xpath, "(//button[contains(., '#{button_name}')])[#{button_index}]")
128
+ else
129
+ button = Element.new("Clicking #{button_name} button", :xpath, "//button[contains(., '#{button_name}')]")
130
+ end
113
131
  begin
114
132
  button.click
115
133
  rescue Exception
116
134
  Log.debug("Button not found - Attempting Link - speed up test by using click_link method if this works...")
117
- link = Element.new("A #{button_name} link", :xpath, "//a[contains(., '#{button_name}')]")
118
- link.click
135
+ click_link button_name, link_index: button_index
119
136
  end
120
137
  end
121
138
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Urban
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler