Class: Sapphire::WebAbstractions::Control
- Inherits:
-
Object
- Object
- Sapphire::WebAbstractions::Control
show all
- Defined in:
- lib/sapphire/WebAbstractions/Controls/Base/Control.rb
Direct Known Subclasses
Button, CheckBox, DropDown, Hyperlink, Image, Label, List, RadioButton, TableCell, TextBox, Title
Instance Method Summary
collapse
Constructor Details
#initialize(browser, hash) ⇒ Control
Returns a new instance of Control.
4
5
6
7
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 4
def initialize(browser, hash)
@browser = browser
@hash = hash
end
|
Instance Method Details
#Click ⇒ Object
72
73
74
75
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 72
def Click
control = self.Find
control.click
end
|
#Equals(value) ⇒ Object
88
89
90
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 88
def Equals(value)
self.Text == value
end
|
#Find ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 9
def Find
if(@hash.has_key?(:id))
FindBy :id
elsif (@hash.has_key?(:name))
FindBy :name
elsif (@hash.has_key?(:xpath))
FindBy :xpath
end
end
|
#FindAll ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 19
def FindAll
if(@hash.has_key?(:id))
FindAllBy :id
elsif (@hash.has_key?(:name))
FindAllBy :name
elsif (@hash.has_key?(:xpath))
FindAllBy :xpath
end
end
|
#FindAllBy(symbol) ⇒ Object
50
51
52
53
54
55
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 50
def FindAllBy(symbol)
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
element = wait.until { x = @browser.find_elements symbol, @hash.fetch(symbol)
x
}
end
|
#FindBy(symbol) ⇒ Object
43
44
45
46
47
48
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 43
def FindBy(symbol)
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
element = wait.until { x = @browser.find_element symbol, @hash.fetch(symbol)
x
}
end
|
#FindParent(hash) ⇒ Object
57
58
59
60
61
62
63
64
65
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 57
def FindParent(hash)
if(hash.has_key?(:id))
@browser.find_element :id, hash.fetch(:id)
elsif (hash.has_key?(:name))
@browser.find_element :name, hash.fetch(:name)
elsif (hash.has_key?(:xpath))
@browser.find_element :xpath, hash.fetch(:xpath)
end
end
|
#FindWithoutWait ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 29
def FindWithoutWait
if(@hash.has_key?(:id))
FindWithoutWaitBy :id
elsif (@hash.has_key?(:name))
FindWithoutWaitBy :name
elsif (@hash.has_key?(:xpath))
FindWithoutWaitBy :xpath
end
end
|
#FindWithoutWaitBy(symbol) ⇒ Object
39
40
41
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 39
def FindWithoutWaitBy(symbol)
@browser.find_element symbol, @hash.fetch(symbol)
end
|
#MouseOver ⇒ Object
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 77
def MouseOver
if(@hash.has_key?(:id))
@browser.execute_script("document.getElementById('"+ @hash.fetch(:id) +"').style.visibility = 'visible'; ")
elsif (@hash.has_key?(:name))
@browser.execute_script("document.getElementById('"+ @hash.fetch(:name) +"').style.visibility = 'visible'; ")
elsif (@hash.has_key?(:xpath))
@browser.execute_script("document.evaluate( '" + @hash.fetch(:xpath) + "', document, null, XPathResult.ANY_TYPE, null ).iterateNext().style.visibility = 'visible'; ")
end
sleep(1)
end
|
#Text ⇒ Object
67
68
69
70
|
# File 'lib/sapphire/WebAbstractions/Controls/Base/Control.rb', line 67
def Text
text = self.Find
text.text
end
|