blackboxd 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/selenium_webdriver_steps.rb +142 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6236d237b5b64a0e49a378330c555f43bf7777a
|
4
|
+
data.tar.gz: ea89050a1f2723b7a2c6f75a4410c110ccbe1e21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ca35f33c4c0d2278f6d433a244d15e949fc0de0286ab0f18988548dec6b5ebbb063e4e9981418e0406e92de2811bcc7ae6b1b214fa9a4e5083bfac2ee2bfe4
|
7
|
+
data.tar.gz: ea79173ea8aa05910dde5099d979dfa11c6cc703663806ad4d3319b5e8030c0ee515d5e03275f2d8a5f4662b17d33f47a3a4331de9d1deb655fde6f1b04cec8b
|
@@ -0,0 +1,142 @@
|
|
1
|
+
Given /I click_on "(.*)" "(.*)"/ do |value, type|
|
2
|
+
steps %Q{
|
3
|
+
* I wait until "#{value}" "#{type}" renders
|
4
|
+
}
|
5
|
+
@driver.find_element(type.to_sym => value).click
|
6
|
+
end
|
7
|
+
|
8
|
+
When /I wait until "(.*)" "(.*)" renders/ do |value, type|
|
9
|
+
if value == "preferences-command" || value == "ui-inline-del" then
|
10
|
+
sleep 2
|
11
|
+
end
|
12
|
+
start_time = Time.now.to_i
|
13
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => @time)
|
14
|
+
wait.until {
|
15
|
+
element = @driver.find_element(type.to_sym => value )
|
16
|
+
element if element.displayed?
|
17
|
+
}
|
18
|
+
end_time = Time.now.to_i - start_time
|
19
|
+
puts (end_time.to_s + " seconds to render " + "<" + type + ">" + value.inspect + "</" + type + ">")
|
20
|
+
end
|
21
|
+
|
22
|
+
Given /I xpath "(.*)" "(.*)"/ do |what, how|
|
23
|
+
steps %Q{
|
24
|
+
* I wait for "#{what}" "#{how}" to render
|
25
|
+
}
|
26
|
+
@driver.find_element(:xpath, ".//" + how + "[text()='" + what + "']").click
|
27
|
+
end
|
28
|
+
|
29
|
+
When /I wait for "(.*)" "(.*)" to render/ do |what, how|
|
30
|
+
if what == "Insight" then
|
31
|
+
puts sleep 2
|
32
|
+
end
|
33
|
+
start_time = Time.now.to_i
|
34
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => @time)
|
35
|
+
wait.until {
|
36
|
+
element = @driver.find_element(:xpath, ".//" + how + "[text()='" + what + "']")
|
37
|
+
element if element.displayed?
|
38
|
+
}
|
39
|
+
end_time = Time.now.to_i - start_time
|
40
|
+
if end_time == 1
|
41
|
+
puts (end_time.to_s + " second to render " + "<" + how + ">" + what.inspect + "</" + how + ">")
|
42
|
+
else
|
43
|
+
puts (end_time.to_s + " seconds to render " + "<" + how + ">" + what.inspect + "</" + how + ">")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
Given /^I am on the (.+)/ do |page_name|
|
48
|
+
@driver.get(path_to(page_name))
|
49
|
+
if page_name == "login page"
|
50
|
+
@driver.get(path_to(page_name))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Given /I fill in "(.*)" with "(.*)"/ do |how, what|
|
55
|
+
if (@driver.all(:id, how).count >= 1 ) then
|
56
|
+
# @driver.find_element(:id, how).clear
|
57
|
+
@driver.find_element(:id, how).send_keys(what)
|
58
|
+
elsif (@driver.all(:class, how).count >=1) then
|
59
|
+
@driver.find_element(:class, how).clear
|
60
|
+
@driver.find_element(:class, how).send_keys(what)
|
61
|
+
elsif (@driver.all(:name, how).count >=1) then
|
62
|
+
@driver.find_element(:name, how).clear
|
63
|
+
@driver.find_element(:name, how).send_keys(what)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
Given /I should (NOT )?see "(.*)"/ do |visibility, what|
|
68
|
+
sleep 2
|
69
|
+
what = what.to_s.strip
|
70
|
+
if (visibility.to_s.strip == 'NOT') then
|
71
|
+
result = @driver.all(:xpath, "//*[text()='" + what + "']")
|
72
|
+
result.count.should == 0
|
73
|
+
else
|
74
|
+
start_time = Time.now.to_i
|
75
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => @time)
|
76
|
+
wait.until {
|
77
|
+
result = @driver.first(:xpath, "//*[text()='" + what + "']")
|
78
|
+
result.displayed?
|
79
|
+
}
|
80
|
+
end_time = Time.now.to_i - start_time
|
81
|
+
puts (end_time.to_s + " seconds to render => " + "#{result.text}" )
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Given /I wait "(.*)"/ do |seconds|
|
86
|
+
sleep seconds.to_i
|
87
|
+
end
|
88
|
+
|
89
|
+
Given /I should (NOT )?be on "(.*)"/ do |visibility, value|
|
90
|
+
sleep 3
|
91
|
+
puts url = @driver.current_url.to_s
|
92
|
+
if (visibility.to_s.strip == 'NOT') then
|
93
|
+
url.should_not include value
|
94
|
+
else
|
95
|
+
url.should include value
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
Given /I maximize browser/ do
|
100
|
+
@driver.manage.window.maximize
|
101
|
+
end
|
102
|
+
|
103
|
+
Given /I refresh the page/ do
|
104
|
+
@driver.execute_script("$(document).ready(function(){
|
105
|
+
location.reload(true);
|
106
|
+
});")
|
107
|
+
sleep 4
|
108
|
+
end
|
109
|
+
|
110
|
+
Given /I mouseover "(.*)"/ do |value|
|
111
|
+
sleep 3
|
112
|
+
el = @driver.find_element(:class, value)
|
113
|
+
@driver.action.move_to(el).perform
|
114
|
+
sleep 2
|
115
|
+
end
|
116
|
+
|
117
|
+
Given /I press the "(.*)" key/ do |value|
|
118
|
+
@driver.action.send_keys(value.to_sym).perform
|
119
|
+
end
|
120
|
+
|
121
|
+
Given /I type in "(.*)"/ do |value|
|
122
|
+
@driver.action.send_keys(value).perform
|
123
|
+
end
|
124
|
+
|
125
|
+
Given /I scroll down "(.*)" times/ do |number|
|
126
|
+
number.to_i.times do
|
127
|
+
@driver.execute_script("window.scrollBy(0,1000)", "")
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
Given /I scroll up/ do
|
132
|
+
@driver.execute_script("window.scrollTop", "")
|
133
|
+
end
|
134
|
+
|
135
|
+
Given /I display page source/ do
|
136
|
+
puts @driver.page_source
|
137
|
+
end
|
138
|
+
|
139
|
+
Given /I accept alert/ do
|
140
|
+
alert = @driver.switch_to.alert
|
141
|
+
alert.accept
|
142
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackboxd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Downie
|
@@ -15,7 +15,8 @@ email: rich@blackboxd.com
|
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
|
-
files:
|
18
|
+
files:
|
19
|
+
- lib/selenium_webdriver_steps.rb
|
19
20
|
homepage: http://blackboxd.com
|
20
21
|
licenses:
|
21
22
|
- MIT
|