Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added href method to Link

  • Loading branch information...
commit 93a4546374e18f1eba162dd15b8bbdcf17357501 1 parent 41eaa5c
@cheezy authored
View
4 ChangeLog
@@ -1,3 +1,7 @@
+=== Version 0.9.6
+* Enhancements
+ * Added href method to Link
+
=== Version 0.9.5
* Enhancements
* Updated to use the latest selenium-webdriver 2.39.0
View
4 cucumber.yml
@@ -5,6 +5,6 @@ std_opts = "--no-source --color --format pretty" # Cucumber::Formatter::Fuubar"
default: DRIVER=WATIR <%= std_opts %> --tags ~@selenium_only
watir_webdriver: DRIVER=WATIR <%= std_opts %> --tags ~@selenium_only
selenium_webdriver: DRIVER=SELENIUM <%= std_opts %> --tags ~@watir_only
-#focus: DRIVER=WATIR <%= std_opts %> --tags ~@selenium_only --tags @focus
-focus: DRIVER=SELENIUM <%= std_opts %> --tags ~@watir_only --tags @focus
+focus: DRIVER=WATIR <%= std_opts %> --tags ~@selenium_only --tags @focus
+#focus: DRIVER=SELENIUM <%= std_opts %> --tags ~@watir_only --tags @focus
View
4 features/link.feature
@@ -42,3 +42,7 @@ Feature: Links
Scenario: Finding a link dynamically
When I select a link while the script is executing
And the page should contain the text "Success"
+
+ Scenario: Getting the href for a link
+ When I get the href for the link
+ Then I should know it was "success.html"
View
12 features/step_definitions/link_steps.rb
@@ -19,6 +19,14 @@
link.click
end
-Then /^I should see that the link exists$/ do
+Then(/^I should see that the link exists$/) do
@page.link_id?.should == true
-end
+end
+
+When(/^I get the href for the link$/) do
+ @href = @page.google_search_id_element.href
+end
+
+Then(/^I should know it was "(.*?)"$/) do |href|
+ @href.should include href
+end
View
1  features/table.feature
@@ -15,7 +15,6 @@ Feature: Table
When I retrieve a table element
Then I should know it exists
-@focus
Scenario: Retrieve the data from a table
When I retrieve a table element
Then the data for row "2" should be "Data1" and "Data2"
View
7 lib/page-object/elements/link.rb
@@ -28,9 +28,14 @@ def self.selenium_mapping
def include_platform_for platform
super
- if platform[:platform] == :selenium_webdriver
+ if platform[:platform] == :watir_webdriver
+ require 'page-object/platforms/watir_webdriver/link'
+ self.class.send :include, PageObject::Platforms::WatirWebDriver::Link
+ elsif platform[:platform] == :selenium_webdriver
require 'page-object/platforms/selenium_webdriver/link'
self.class.send :include, PageObject::Platforms::SeleniumWebDriver::Link
+ else
+ raise ArgumentError, "expect platform to be :watir_webdriver or :selenium_webdriver"
end
end
end
View
9 lib/page-object/platforms/selenium_webdriver/link.rb
@@ -9,8 +9,15 @@ module Link
def value
raise "value not available on link element with Selenium"
end
+
+ #
+ # return the href for the link
+ #
+ def href
+ attribute('href')
+ end
end
end
end
-end
+end
View
15 lib/page-object/platforms/watir_webdriver/link.rb
@@ -0,0 +1,15 @@
+module PageObject
+ module Platforms
+ module WatirWebDriver
+ module Link
+
+ #
+ # return the href for the link
+ #
+ def href
+ element.href
+ end
+ end
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.