Class: SpecTest::Platforms::SeleniumWebDriver::PlatformObject
- Inherits:
-
Object
- Object
- SpecTest::Platforms::SeleniumWebDriver::PlatformObject
- Defined in:
- lib/spectest/platform_selenium/platform_object.rb
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.
6 7 8 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 6 def initialize(browser) @browser = browser end |
Instance Method Details
#click_button_for(locator) ⇒ Object
Platform method to click a button object. See SpecTest::Generators#button
92 93 94 95 96 97 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 92 def (locator) key, value, enclosers = get_platform_locator_for(locator, WebObjects::Button, 'input', :type => 'submit') switch_to_encloser(enclosers) @browser.find_element(key, value).click @browser.switch_to.default_content unless enclosers.nil? end |
#click_link_for(locator) ⇒ Object
Platform method to click a link object. See SpecTest::Generators#link
41 42 43 44 45 46 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 41 def click_link_for(locator) key, value, enclosers = get_platform_locator_for(locator, WebObjects::Link, 'a') switch_to_encloser(enclosers) @browser.find_element(key, value).click @browser.switch_to.default_content unless enclosers.nil? 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
82 83 84 85 86 87 88 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 82 def (locator) key, value, enclosers = get_platform_locator_for(locator, WebObjects::Button, 'input', :type => 'submit') switch_to_encloser(enclosers) web_object = @browser.find_element(key, value) @browser.switch_to.default_content unless enclosers.nil? WebObjects::Button.new(web_object, :platform => :selenium_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
31 32 33 34 35 36 37 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 31 def get_link_for(locator) key, value, enclosers = get_platform_locator_for(locator, WebObjects::Link, 'a') switch_to_encloser(enclosers) web_object = @browser.find_element(key, value) @browser.switch_to.default_content unless enclosers.nil? WebObjects::Link.new(web_object, :platform => :selenium_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 57 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 51 def get_text_field_for(locator) key, value, enclosers = get_platform_locator_for(locator, WebObjects::TextField, 'input', :type => 'text') switch_to_encloser(enclosers) web_object = @browser.find_element(key, value) @browser.switch_to.default_content unless enclosers.nil? WebObjects::TextField.new(web_object, :platform => :selenium_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
61 62 63 64 65 66 67 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 61 def get_text_field_value_for(locator) key, value, enclosers = get_platform_locator_for(locator, WebObjects::TextField, 'input', :type => 'text') switch_to_encloser(enclosers) value = @browser.find_element(key, value).attribute('value') @browser.switch_to.default_content unless enclosers.nil? value end |
#navigate_to(url) ⇒ Object
Platform method to navigate to a specified URL. See SpecTest#navigate_to
12 13 14 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 12 def navigate_to(url) @browser.navigate.to 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
71 72 73 74 75 76 77 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 71 def set_text_field_value_for(locator, text) key, value, enclosers = get_platform_locator_for(locator, WebObjects::TextField, 'input', :type => 'text') switch_to_encloser(enclosers) @browser.find_element(key, value).clear @browser.find_element(key, value).send_keys(text) @browser.switch_to.default_content unless enclosers.nil? end |
#text ⇒ Object
Platform method to retrieve text from the current page. See SpecTest#text
24 25 26 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 24 def text @browser.find_element(:tag_name, 'body').text end |
#title ⇒ Object
Platform method to retrieve the title for the current page. See SpecTest#title
18 19 20 |
# File 'lib/spectest/platform_selenium/platform_object.rb', line 18 def title @browser.title end |