gem0 0.1.0 → 0.1.1
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/Gemfile.lock +1 -1
- data/bin/assertion.rb +93 -0
- data/bin/browser.rb +48 -0
- data/bin/check.rb +22 -0
- data/bin/click.rb +29 -0
- data/bin/env.rb +12 -0
- data/bin/fill.rb +56 -0
- data/bin/gem0.rb +5 -0
- data/bin/select.rb +40 -0
- data/bin/unclassified.rb +19 -0
- data/gem0-0.1.0.gem +0 -0
- data/gem0.gemspec +1 -1
- metadata +11 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '000575388d600916a4fef54501e056eb4cd7636c'
|
4
|
+
data.tar.gz: 4ce97dba617bef920a6cf6778371b7157a33945f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40624b9083fb6591f359ee979062b8dc7e542bd2fc52de49d419a3476bd1f0137e322a7aa1c385a807c2bcf6c66bed442ad5b41fcae04567443f5d3ce5a6757c
|
7
|
+
data.tar.gz: '08d8a9b50ee97d20d30f21803ab5d7cbf415b757525618e62fd5caa712da7f36e04c5872cf05f9c9ce48c1bbefe2d31a5e0ec20fcfb840cd1a1ed0fa993714ba'
|
data/Gemfile.lock
CHANGED
data/bin/assertion.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require_relative '../bin/env'
|
2
|
+
#require_relative '../../bdd-helper/support/config'
|
3
|
+
|
4
|
+
include BaseConstants
|
5
|
+
|
6
|
+
Then(/^page (should|should_not) contain "([^"]*)" content$/) do |condition, content|
|
7
|
+
# E.g. : page should contain "Test" content
|
8
|
+
# E.g. : page should_not contain "Test" content
|
9
|
+
# page.should have_content(content, count: count, wait: @timeout)
|
10
|
+
sleep 1
|
11
|
+
if condition == 'should'
|
12
|
+
page.should have_content(content, wait: @timeout)
|
13
|
+
|
14
|
+
elsif condition == 'should_not'
|
15
|
+
page.should_not have_content(content, wait: @timeout)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Then(/^page (should|should_not) contain the following contents:$/) do |condition, table|
|
20
|
+
sleep 1
|
21
|
+
values = table.raw
|
22
|
+
values.each {|raw|
|
23
|
+
if condition == 'should'
|
24
|
+
page.should have_content(raw[0], wait: @timeout)
|
25
|
+
elsif condition == 'should_not'
|
26
|
+
page.should_not have_content(raw[0], wait: @timeout)
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
Then(/^page (should|should_not) contain "([^"]*)" "([^"]*)" web element/) do |condition, web_element_type, web_element|
|
32
|
+
# E.g. : page should contain "css" "#test .form" web element
|
33
|
+
sleep 1
|
34
|
+
if condition == 'should'
|
35
|
+
page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
|
36
|
+
|
37
|
+
elsif condition == 'should_not'
|
38
|
+
page.should_not have_selector(:"#{web_element_type}", web_element, wait: @timeout)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Then(/^page (should|should_not) contain "([^"]*)" button$/) do |condition, button|
|
43
|
+
# E.g. : page should contain "Save" button
|
44
|
+
# E.g. : page should_not contain "Save" button
|
45
|
+
# page.should have_content(content, count: count, wait: @timeout)
|
46
|
+
sleep 1
|
47
|
+
if condition == 'should'
|
48
|
+
page.should have_button(button, wait: @timeout)
|
49
|
+
|
50
|
+
elsif condition == 'should_not'
|
51
|
+
page.should_not have_button(button, wait: @timeout)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
Then(/^"([^"]*)" button (should|should_not) be disabled$/) do |button, condition|
|
56
|
+
sleep 1
|
57
|
+
if condition == 'should'
|
58
|
+
find_button button, disabled: true
|
59
|
+
|
60
|
+
elsif condition == 'should_not'
|
61
|
+
find_button button, disabled: false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
When(/^"([^"]*)" checkbox should be (checked|unchecked)$/) do |checkbox, condition|
|
66
|
+
# E.g. : .. "Agree" checkbox should be checked
|
67
|
+
# checkbox can be label, value or id
|
68
|
+
if condition == 'checked'
|
69
|
+
expect(page).to have_field(checkbox, checked: true, visible: true)
|
70
|
+
elsif condition == 'unchecked'
|
71
|
+
expect(page).to have_field(checkbox, checked: false, visible: true)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
When(/^"([^"]*)" radio button should be (selected|unselected)$/) do |radio_button, condition|
|
76
|
+
# E.g. : .. "Yes" radio button should be selected
|
77
|
+
# radio_button can be name, id or label
|
78
|
+
if condition == 'checked'
|
79
|
+
expect(page).to have_field(radio_button, checked: true, visible: true)
|
80
|
+
elsif condition == 'unchecked'
|
81
|
+
expect(page).to have_field(radio_button, checked: false, visible: true)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Then(/^validation message should be "([^"]*)" about "([^"]*)" field$/) do |expected_message, element_value|
|
86
|
+
sleep 1.5
|
87
|
+
if page.has_css?(element_value)
|
88
|
+
expected_message.should == page.execute_script("return document.querySelector('#{element_value}').innerHTML.trim();")
|
89
|
+
|
90
|
+
elsif page.has_no_css?(element_value)
|
91
|
+
expected_message.should == ''
|
92
|
+
end
|
93
|
+
end
|
data/bin/browser.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require_relative '../bin/env'
|
2
|
+
#require_relative '../../bdd-helper/support/config'
|
3
|
+
|
4
|
+
And(/^refresh the page$/) do
|
5
|
+
page.evaluate_script('window.location.reload()')
|
6
|
+
sleep 1
|
7
|
+
# location = current_url
|
8
|
+
# page.driver.browser.navigate.refresh
|
9
|
+
# sleep 1
|
10
|
+
# current_url.should == location
|
11
|
+
end
|
12
|
+
|
13
|
+
When(/^navigate browser to "([^"]*)" url$/) do |url|
|
14
|
+
visit url
|
15
|
+
#current_url.should == url
|
16
|
+
end
|
17
|
+
|
18
|
+
# When(/^navigate browser to "([^"]*)" path$/) do |path|
|
19
|
+
# visit $URL + path
|
20
|
+
# current_url.should == $URL + path
|
21
|
+
# end
|
22
|
+
|
23
|
+
And(/^switch window to (first|last) opened$/) do |condition|
|
24
|
+
if condition == 'first'
|
25
|
+
page.driver.browser.switch_to.window(page.driver.browser.window_handles.first)
|
26
|
+
elsif condition == 'last'
|
27
|
+
page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Then(/^user should redirected to "([^"]*)" path$/) do |path|
|
32
|
+
page.should have_current_path(path, wait: $TIMEOUT)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Given(/^user on main page$/) do
|
36
|
+
# current_url.should == @url + '/'
|
37
|
+
# end
|
38
|
+
|
39
|
+
Then(/^alert message (should|should_not) be "([^"]*)" seçiniz."$/) do |condition, message|
|
40
|
+
if condition == 'should'
|
41
|
+
resp = page.driver.browser.switch_to.alert.text
|
42
|
+
resp.should == message
|
43
|
+
|
44
|
+
elsif condition == 'should_not'
|
45
|
+
resp = page.driver.browser.switch_to.alert.text
|
46
|
+
resp.should_not == message
|
47
|
+
end
|
48
|
+
end
|
data/bin/check.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative '../bin/env'
|
2
|
+
|
3
|
+
When(/^(check|uncheck) "([^"]*)" checkbox$/) do |condition, checkbox|
|
4
|
+
# E.g. : .. check "Agree" checkbox
|
5
|
+
# checkbox can be name, id or label
|
6
|
+
if condition == 'check'
|
7
|
+
check(checkbox)
|
8
|
+
elsif condition == 'uncheck'
|
9
|
+
uncheck(checkbox)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
When(/^choose "([^"]*)" radio button$/) do |radio_button|
|
14
|
+
# E.g. : .. choose "Yes" radio button
|
15
|
+
# radio_button can be name, id or label
|
16
|
+
choose(radio_button)
|
17
|
+
end
|
18
|
+
|
19
|
+
And(/^check type "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
|
20
|
+
page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
|
21
|
+
find(:"#{web_element_type}", web_element).set(true)
|
22
|
+
end
|
data/bin/click.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative '../bin/env'
|
2
|
+
|
3
|
+
When(/^click "([^"]*)" (link|button) by (id|title|text)$/) do |identifier, identifier_type, condition|
|
4
|
+
# E.g: .. click "Save" button by text
|
5
|
+
Capybara.ignore_hidden_elements = false
|
6
|
+
if condition == 'title' || condition == 'text'
|
7
|
+
page.should have_content(identifier)
|
8
|
+
|
9
|
+
elsif condition == 'id'
|
10
|
+
page.should have_selector(:id, identifier)
|
11
|
+
end
|
12
|
+
|
13
|
+
if identifier_type == 'link'
|
14
|
+
# link can be id, title or text
|
15
|
+
Capybara.ignore_hidden_elements = false
|
16
|
+
click_link(identifier)
|
17
|
+
|
18
|
+
elsif identifier_type == 'button'
|
19
|
+
# button can be id, title, value or text
|
20
|
+
Capybara.ignore_hidden_elements = false
|
21
|
+
click_button(identifier)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Then(/^click type "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
|
26
|
+
# E.g: .. click type "id" value "save" web element
|
27
|
+
page.should have_selector(:"#{web_element_type}", web_element)
|
28
|
+
find(:"#{web_element_type}", web_element).click
|
29
|
+
end
|
data/bin/env.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'capybara'
|
2
|
+
require 'capybara/cucumber'
|
3
|
+
require 'capybara/dsl'
|
4
|
+
#require 'capybara/poltergeist'
|
5
|
+
require 'capybara/rspec'
|
6
|
+
require 'rubygems'
|
7
|
+
require 'rspec'
|
8
|
+
require 'rspec/expectations'
|
9
|
+
require 'rspec/matchers'
|
10
|
+
require 'selenium-cucumber'
|
11
|
+
require 'selenium/webdriver'
|
12
|
+
require 'selenium/webdriver/common/wait'
|
data/bin/fill.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative '../bin/env'
|
2
|
+
|
3
|
+
And(/^fill "([^"]*)" with "([^"]*)"$/) do |field, value|
|
4
|
+
# E.g : ..fill "Phone Number" with "5555555555"
|
5
|
+
# field can be name, id or label
|
6
|
+
fill_in(field, with: value)
|
7
|
+
end
|
8
|
+
|
9
|
+
And(/^fill input boxes with these values:$/) do |table|
|
10
|
+
values = table.raw
|
11
|
+
values.each {|raw| fill_in(raw[0], with: raw[1])}
|
12
|
+
end
|
13
|
+
|
14
|
+
Then(/^fill type "([^"]*)" value "([^"]*)" web element with "([^"]*)"$/) do |web_element_type, web_element, value|
|
15
|
+
# E.g: .. click type "id" value "save" web element
|
16
|
+
page.should have_selector(:"#{web_element_type}", web_element, wait: @timeout)
|
17
|
+
find(:"#{web_element_type}", web_element).set(value)
|
18
|
+
end
|
19
|
+
|
20
|
+
# =scoping=
|
21
|
+
# within("//li[@id='employee']") do
|
22
|
+
# fill_in 'Name', :with => 'Jimmy'
|
23
|
+
# end
|
24
|
+
# within(:css, "li#employee") do
|
25
|
+
# fill_in 'Name', :with => 'Jimmy'
|
26
|
+
# end
|
27
|
+
# within_fieldset('Employee') do
|
28
|
+
# fill_in 'Name', :with => 'Jimmy'
|
29
|
+
# end
|
30
|
+
# within_table('Employee') do
|
31
|
+
# fill_in 'Name', :with => 'Jimmy'
|
32
|
+
# end
|
33
|
+
|
34
|
+
And(/^fill "([^"]*)" with random (email|password|name|gsm)$/) do |field, condition|
|
35
|
+
def generate_code(number, condition)
|
36
|
+
if condition == 'email'
|
37
|
+
charset = Array('A'..'Z') + Array('a'..'z') + Array(0..9)
|
38
|
+
Array.new(number) {charset.sample}.join + "@gmail.com"
|
39
|
+
|
40
|
+
elsif condition == 'password'
|
41
|
+
charset = Array('A'..'Z') + Array('a'..'z') + Array(0..9)
|
42
|
+
Array.new(number) {charset.sample}.join
|
43
|
+
|
44
|
+
elsif condition == 'name'
|
45
|
+
charset = Array('A'..'Z') + Array('a'..'z')
|
46
|
+
Array.new(number) {charset.sample}.join
|
47
|
+
|
48
|
+
elsif condition == 'gsm'
|
49
|
+
charset = Array(0..9)
|
50
|
+
Array.new(7) {charset.sample}.join
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
var = generate_code(10, condition)
|
55
|
+
fill_in(field, with: var)
|
56
|
+
end
|
data/bin/gem0.rb
ADDED
data/bin/select.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../bin/env'
|
2
|
+
|
3
|
+
And(/^select "([^"]*)" as "([^"]*)" from dropdown$/) do |dropdown, option|
|
4
|
+
# E.g : select "Country" as "United States" from dropdown
|
5
|
+
# E.g : select "United States", from: "Country", :match => :first ===>> to select first matched option
|
6
|
+
# dropdown can be id, name, label text
|
7
|
+
select(option, from: dropdown) # OR ==>> find('#select_id').select('value')
|
8
|
+
end
|
9
|
+
|
10
|
+
Then /^"([^"]*)" (should|should_not) be selected for "([^"]*)" dropdown$/ do |selected_option, condition, dropdown|
|
11
|
+
# E.g : "United States" should be selected for "Country" dropdown
|
12
|
+
if condition == 'should'
|
13
|
+
page.should have_select(dropdown, selected: selected_option)
|
14
|
+
|
15
|
+
elsif condition == 'should_not'
|
16
|
+
page.should_not have_select(dropdown, selected: selected_option)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^"([^"]*)" dropdown (should|should_not) contain "([^"]*)" option$/ do |dropdown, condition, option_text|
|
21
|
+
# E.g : .. "Country" dropdown should contain "United States" option
|
22
|
+
if condition == 'should'
|
23
|
+
page.should have_select(dropdown, with_options: [option_text])
|
24
|
+
|
25
|
+
elsif condition == 'should_not'
|
26
|
+
page.should_not have_select(dropdown, with_options: [option_text])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Then /^"([^"]*)" dropdown (should|should_not) contain following options:$/ do |dropdown, condition, table|
|
31
|
+
values = table.raw
|
32
|
+
sleep 1
|
33
|
+
values.each {|raw|
|
34
|
+
if condition == 'should'
|
35
|
+
page.should have_select(dropdown, with_options: [raw[0]])
|
36
|
+
|
37
|
+
elsif condition == 'should_not'
|
38
|
+
page.should_not have_select(dropdown, with_options: [raw[0]])
|
39
|
+
end}
|
40
|
+
end
|
data/bin/unclassified.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../bin/env'
|
2
|
+
|
3
|
+
When(/^hover to "([^"]*)" value "([^"]*)" web element$/) do |web_element_type, web_element|
|
4
|
+
find(:"#{web_element_type}", web_element).trigger(:mouseover)
|
5
|
+
end
|
6
|
+
|
7
|
+
When(/^wait "([^"]*)" seconds$/) do |sec_value|
|
8
|
+
sleep sec_value.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
And(/^generate random string and type into "([^"]*)"$/) do |field|
|
12
|
+
charset = (0...8).map {(65 + rand(26)).chr}.join
|
13
|
+
fill_in(field, with: charset)
|
14
|
+
end
|
15
|
+
|
16
|
+
And(/^execute javascript code "([^"]*)"/) do |code|
|
17
|
+
page.execute_script(code)
|
18
|
+
sleep 2
|
19
|
+
end
|
data/gem0-0.1.0.gem
ADDED
Binary file
|
data/gem0.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Quaranto
|
@@ -20,9 +20,19 @@ files:
|
|
20
20
|
- Gemfile.lock
|
21
21
|
- README.md
|
22
22
|
- Rakefile
|
23
|
+
- bin/assertion.rb
|
24
|
+
- bin/browser.rb
|
25
|
+
- bin/check.rb
|
26
|
+
- bin/click.rb
|
23
27
|
- bin/console
|
28
|
+
- bin/env.rb
|
29
|
+
- bin/fill.rb
|
30
|
+
- bin/gem0.rb
|
31
|
+
- bin/select.rb
|
24
32
|
- bin/setup
|
33
|
+
- bin/unclassified.rb
|
25
34
|
- gem0-0.0.0.gem
|
35
|
+
- gem0-0.1.0.gem
|
26
36
|
- gem0.gemspec
|
27
37
|
homepage: http://rubygems.org/gems/gem0
|
28
38
|
licenses:
|