Class: SpecTest::Platforms::WatirWebDriver::PlatformObject
- Inherits:
-
Object
- Object
- SpecTest::Platforms::WatirWebDriver::PlatformObject
- Defined in:
- lib/spectest/platform_watir/platform_object.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
Instance Method Summary collapse
-
#click_button_for(locator) ⇒ Object
Platform method to click a button object.
-
#click_link_for(locator) ⇒ Object
Platform method to click a link object.
-
#get_button_for(locator) ⇒ Object
Platform method to return a button object.
-
#get_link_for(locator) ⇒ Object
Platform method to return a link object.
-
#get_text_field_for(locator) ⇒ Object
Platform method to return a text field object.
-
#get_text_field_value_for(locator) ⇒ Object
Platform method to get the value in a text field object.
-
#initialize(browser) ⇒ PlatformObject
constructor
A new instance of PlatformObject.
-
#navigate_to(url) ⇒ Object
Platform method to navigate to a specified URL.
-
#set_text_field_value_for(locator, text) ⇒ Object
Platform method to set a value in a text field object.
-
#text ⇒ Object
Platform method to retrieve text from the current page.
-
#title ⇒ Object
Platform method to retrieve the title for the current page.
Constructor Details
#initialize(browser) ⇒ PlatformObject
Returns a new instance of PlatformObject.
8 9 10 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 8 def initialize(browser) @browser = browser end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
6 7 8 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 6 def browser @browser end |
Instance Method Details
#click_button_for(locator) ⇒ Object
Platform method to click a button object. See SpecTest::Generators#button
88 89 90 91 92 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 88 def (locator) identifier, enclosers = get_platform_locator_for(locator, WebObjects::Button) @browser.instance_eval "#{nested_by(enclosers)}button(locator).click" switch_to_default(enclosers) end |
#click_link_for(locator) ⇒ Object
Platform method to click a link object. See SpecTest::Generators#link
42 43 44 45 46 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 42 def click_link_for(locator) locator, enclosers = get_platform_locator_for(locator, WebObjects::Link) @browser.instance_eval "#{nested_by(enclosers)}link(locator).click if locator" switch_to_default(enclosers) end |
#get_button_for(locator) ⇒ Object
Platform method to return a button object. Button objects are of type: SpecTest::WebObjects::Button See SpecTest::Generators#button
79 80 81 82 83 84 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 79 def (locator) identifier, enclosers = get_platform_locator_for(locator, WebObjects::Button) web_object = @browser.instance_eval "#{nested_by(enclosers)}button(locator)" switch_to_default(enclosers) WebObjects::Button.new(web_object, :platform => :watir_webdriver) end |
#get_link_for(locator) ⇒ Object
Platform method to return a link object. Link objects are of type: SpecTest::WebObjects::Link See SpecTest::Generators#link
33 34 35 36 37 38 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 33 def get_link_for(locator) locator, enclosers = get_platform_locator_for(locator, WebObjects::Link) web_object = @browser.instance_eval "#{nested_by(enclosers)}link(locator)" switch_to_default(enclosers) WebObjects::Link.new(web_object, :platform => :watir_webdriver) end |
#get_text_field_for(locator) ⇒ Object
Platform method to return a text field object. Text field objects are of type: SpecTest::WebObjects::TextField See SpecTest::Generators#text_field
51 52 53 54 55 56 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 51 def get_text_field_for(locator) identifier, enclosers = get_platform_locator_for(locator, WebObjects::TextField) web_object = @browser.instance_eval "#{nested_by(enclosers)}text_field(locator)" switch_to_default(enclosers) WebObjects::TextField.new(web_object, :platform => :watir_webdriver) end |
#get_text_field_value_for(locator) ⇒ Object
Platform method to get the value in a text field object. See SpecTest::Generators#text_field
60 61 62 63 64 65 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 60 def get_text_field_value_for(locator) identifier, enclosers = get_platform_locator_for(locator, WebObjects::TextField) value = @browser.instance_eval "#{nested_by(enclosers)}text_field(locator).value" switch_to_default(enclosers) value end |
#navigate_to(url) ⇒ Object
Platform method to navigate to a specified URL. See SpecTest#navigate_to
14 15 16 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 14 def navigate_to(url) @browser.goto url end |
#set_text_field_value_for(locator, text) ⇒ Object
Platform method to set a value in a text field object. See SpecTest::Generators#text_field
69 70 71 72 73 74 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 69 def set_text_field_value_for(locator, text) identifier, enclosers = get_platform_locator_for(locator, WebObjects::TextField) SpecTest::trace("set_text_field_value_for: #{identifier}, #{enclosers}") @browser.instance_eval "#{nested_by(enclosers)}text_field(locator).set(text)" switch_to_default(enclosers) end |
#text ⇒ Object
Platform method to retrieve text from the current page. See SpecTest#text
26 27 28 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 26 def text @browser.text end |
#title ⇒ Object
Platform method to retrieve the title for the current page. See SpecTest#title
20 21 22 |
# File 'lib/spectest/platform_watir/platform_object.rb', line 20 def title @browser.title end |