Class: SpecTest::Platforms::WatirWebDriver::PlatformObject

Inherits:
Object
  • Object
show all
Defined in:
lib/spectest/platform_watir/platform_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#browserObject (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 click_button_for(locator)
  identifier, enclosers = get_platform_locator_for(locator, WebObjects::Button)
  @browser.instance_eval "#{nested_by(enclosers)}button(locator).click"
  switch_to_default(enclosers)
end

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 get_button_for(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

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

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

#textObject

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

#titleObject

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