testnow 0.1.1 → 0.1.2
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/README.md +11 -7
- data/bin/testnow +11 -11
- data/data/showtime/Gemfile +2 -1
- data/data/showtime/Gemfile_rspec +2 -1
- data/data/showtime/Rakefile_rspec +1 -1
- data/data/showtime/cucumber.yml +1 -1
- data/data/showtime/env.rb +1 -0
- data/data/showtime/hooks.rb +9 -14
- data/data/showtime/spec_helper.rb +2 -2
- data/data/showtime/testnow.feature +14 -0
- data/data/showtime/testnow_page.rb +76 -0
- data/data/showtime/testnow_spec.rb +21 -0
- data/data/showtime/testnow_steps.rb +33 -0
- data/data/showtime/watir/Gemfile +2 -1
- data/data/showtime/watir/Gemfile_rspec +2 -2
- data/data/showtime/watir/env.rb +2 -1
- data/data/showtime/watir/hooks.rb +9 -14
- data/data/showtime/watir/spec_helper.rb +3 -3
- data/data/showtime/watir/testnow_page.rb +80 -0
- data/data/showtime/watir/testnow_spec.rb +21 -0
- data/data/showtime/watir/testnow_steps.rb +31 -0
- data/lib/testnow.rb +6 -2
- data/lib/testnow/phantomjs.rb +22 -0
- data/lib/testnow/version +1 -1
- metadata +15 -14
- data/data/showtime/github.feature +0 -11
- data/data/showtime/github_page.rb +0 -30
- data/data/showtime/github_spec.rb +0 -18
- data/data/showtime/github_steps.rb +0 -24
- data/data/showtime/watir/github_page.rb +0 -29
- data/data/showtime/watir/github_spec.rb +0 -18
- data/data/showtime/watir/github_steps.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec532a191afce5e92480eba76d1891c7b80e10c
|
4
|
+
data.tar.gz: 89baf5dcabc8330d70473394d3e9606e7f305778
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bb4dd60127154883aee1e8d26038a37448655b0f4004cd0465b7d837b1bb96896b9f82b8728be546da3d9a556841113cb878bf0234af9109c78d322344f011d
|
7
|
+
data.tar.gz: 27e254b120cac5a8dd0a11e201f38fd1bc942594bea2812312be2f2683c2564d8c43a87041c9e092cb0c25835e280a76c99ebe40171c779f1ac721a5aebd8b09
|
data/README.md
CHANGED
@@ -29,16 +29,20 @@ An instant WebDriver-Ruby-Cucumber or WebDriver-Ruby-RSpec framework which has a
|
|
29
29
|
|
30
30
|
## Installation
|
31
31
|
There are multiple ways in which you can install and use testnow gem.
|
32
|
-
You must have Ruby installed before you can install this gem.
|
32
|
+
You must have Ruby(>2.0) installed before you can install this gem.
|
33
33
|
|
34
34
|
### <a name="gem" /> 1. Install using gem command
|
35
|
-
Just use following command from you Terminal.
|
35
|
+
Just use following command from you Terminal.
|
36
|
+
Usually installing testnow using gem command is always advised in cases of creating a new framework from scratch.
|
37
|
+
For existing framework, see next section (Install using bundler).
|
36
38
|
```
|
37
39
|
gem install testnow
|
38
40
|
```
|
39
41
|
|
40
42
|
### <a name="bundler" /> 2. Install using bundler
|
41
|
-
You can include it in your Gemfile and run bundle install
|
43
|
+
You can include it in your Gemfile and run bundle install.
|
44
|
+
This is the preferred way to do it incase of adding testnow to an existing framework.
|
45
|
+
To create a new framework from scratch, there would be no Gemfile, then please install testnow using gem command (Previous section).
|
42
46
|
|
43
47
|
```
|
44
48
|
gem 'testnow'
|
@@ -195,11 +199,11 @@ rake testnow BROWSER="Mobile Chrome" DEVICE=Google_Nexus_6
|
|
195
199
|
## Browsers
|
196
200
|
As mentioned in the above section that there is a variable exposed called _BROWSER_ but what are the values to be passed and which OS-Browsers combinations are supported, well here is a index grid below:
|
197
201
|
|
198
|
-
| OS | Chrome | Firefox (v47-) | Firefox Gecko (v48+) | IE 11/10 | Edge | Opera | PhantomJS | Chrome Mobile[2]
|
202
|
+
| OS | Chrome | Firefox (v47-) | Firefox Gecko (v48+) | IE 11/10 | Edge | Opera | PhantomJS | Chrome Mobile[2] |
|
199
203
|
|---|---|---|---|---|---|---|---|---|
|
200
|
-
| Linux | Supported | Supported | Supported | N/A | N/A | Supported[1] |
|
201
|
-
| Mac | Supported | Supported | Supported | N/A | N/A | Supported[1] |
|
202
|
-
| Windows | Supported | Supported | Supported | Supported | Supported[3]| Coming Soon! |
|
204
|
+
| Linux | Supported | Supported | Supported | N/A | N/A | Supported[1] | Supported | Supported |
|
205
|
+
| Mac | Supported | Supported | Supported | N/A | N/A | Supported[1] | Supported | Supported |
|
206
|
+
| Windows | Supported | Supported | Supported | Supported | Supported[3]| Coming Soon! | Supported | Supported |
|
203
207
|
|
204
208
|
Note:
|
205
209
|
[1] Currently it is expected that the Opera webdriver binary is present inside "/usr/local/bin/operadriver, soon this path will be made customizable and exposaed as a varibale.
|
data/bin/testnow
CHANGED
@@ -56,7 +56,7 @@ def cucumber_now(framework="cucumber")
|
|
56
56
|
FileUtils.makedirs(@report_dir)
|
57
57
|
|
58
58
|
print "Creating feature file inside scenarios directory."
|
59
|
-
FileUtils.copy(@showtime_dir+"/
|
59
|
+
FileUtils.copy(@showtime_dir+"/testnow.feature", @scenario_dir)
|
60
60
|
|
61
61
|
if framework == "watir"
|
62
62
|
print "Creating config files -- hooks.rb -- used for setup and teardown purpose."
|
@@ -65,10 +65,10 @@ def cucumber_now(framework="cucumber")
|
|
65
65
|
FileUtils.copy(@showtime_dir+"/watir/env.rb", @support_dir)
|
66
66
|
|
67
67
|
print "Creating step definition file inside the steps directory"
|
68
|
-
FileUtils.copy(@showtime_dir+"/watir/
|
68
|
+
FileUtils.copy(@showtime_dir+"/watir/testnow_steps.rb", @steps_dir)
|
69
69
|
|
70
70
|
print "Creating page class file inside the page directory."
|
71
|
-
FileUtils.copy(@showtime_dir+"/watir/
|
71
|
+
FileUtils.copy(@showtime_dir+"/watir/testnow_page.rb", @page_dir)
|
72
72
|
|
73
73
|
print "Creating Gemfile -- used to contain all required gems information."
|
74
74
|
FileUtils.copy(@showtime_dir+"/watir/Gemfile", @root_dir)
|
@@ -79,10 +79,10 @@ def cucumber_now(framework="cucumber")
|
|
79
79
|
FileUtils.copy(@showtime_dir+"/env.rb", @support_dir)
|
80
80
|
|
81
81
|
print "Creating step definition file inside the steps directory"
|
82
|
-
FileUtils.copy(@showtime_dir+"/
|
82
|
+
FileUtils.copy(@showtime_dir+"/testnow_steps.rb", @steps_dir)
|
83
83
|
|
84
84
|
print "Creating page class file inside the page directory."
|
85
|
-
FileUtils.copy(@showtime_dir+"/
|
85
|
+
FileUtils.copy(@showtime_dir+"/testnow_page.rb", @page_dir)
|
86
86
|
|
87
87
|
print "Creating Gemfile -- used to contain all required gems information."
|
88
88
|
FileUtils.copy(@showtime_dir+"/Gemfile", @root_dir)
|
@@ -105,7 +105,7 @@ def cucumber_now(framework="cucumber")
|
|
105
105
|
system("bundle install --gemfile=$(pwd)/#{@base}/Gemfile")
|
106
106
|
print "Dependency installation completed successfully.\n\n"
|
107
107
|
else
|
108
|
-
print "You can do this later also. Just cd into
|
108
|
+
print "You can do this later also. Just cd into #{@base} directory and run 'bundle install'\n\n"
|
109
109
|
exit 1
|
110
110
|
end
|
111
111
|
|
@@ -172,10 +172,10 @@ def rspec_now(framework="cucumber")
|
|
172
172
|
FileUtils.copy(@showtime_dir+"/watir/Gemfile_rspec", @root_dir+"/Gemfile")
|
173
173
|
|
174
174
|
print "Creating spec file inside the scenarios directory."
|
175
|
-
FileUtils.copy(@showtime_dir+"/watir/
|
175
|
+
FileUtils.copy(@showtime_dir+"/watir/testnow_spec.rb", @scenario_dir)
|
176
176
|
|
177
177
|
print "Creating page class file inside the pages directory."
|
178
|
-
FileUtils.copy(@showtime_dir+"/watir/
|
178
|
+
FileUtils.copy(@showtime_dir+"/watir/testnow_page.rb", @pages_dir)
|
179
179
|
else
|
180
180
|
print "Creating config file -- spec_helper.rb -- used for dependency declaration and global setup-teardown"
|
181
181
|
FileUtils.copy(@showtime_dir+"/spec_helper.rb", @spec_dir)
|
@@ -184,10 +184,10 @@ def rspec_now(framework="cucumber")
|
|
184
184
|
FileUtils.copy(@showtime_dir+"/Gemfile_rspec", @root_dir+"/Gemfile")
|
185
185
|
|
186
186
|
print "Creating spec file inside the scenarios directory."
|
187
|
-
FileUtils.copy(@showtime_dir+"/
|
187
|
+
FileUtils.copy(@showtime_dir+"/testnow_spec.rb", @scenario_dir)
|
188
188
|
|
189
189
|
print "Creating page class file inside the pages directory."
|
190
|
-
FileUtils.copy(@showtime_dir+"/
|
190
|
+
FileUtils.copy(@showtime_dir+"/testnow_page.rb", @pages_dir)
|
191
191
|
end
|
192
192
|
|
193
193
|
print "Creating Rakefile -- used to write automation execution tasks."
|
@@ -223,7 +223,7 @@ end
|
|
223
223
|
|
224
224
|
def print(msg)
|
225
225
|
puts "\n"
|
226
|
-
puts "
|
226
|
+
puts "=>=> " + msg
|
227
227
|
sleep 0.5
|
228
228
|
end
|
229
229
|
|
data/data/showtime/Gemfile
CHANGED
data/data/showtime/Gemfile_rspec
CHANGED
@@ -3,5 +3,5 @@ require 'rspec/core/rake_task'
|
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new("testnow") do |role|
|
5
5
|
role.pattern="spec/scenarios/*_spec.rb"
|
6
|
-
role.rspec_opts = ["--format", "html", "--out", "reports/
|
6
|
+
role.rspec_opts = ["--format", "html", "--out", "reports/testnow_report.html"]
|
7
7
|
end
|
data/data/showtime/cucumber.yml
CHANGED
@@ -1 +1 @@
|
|
1
|
-
default: --require features --no-source --color --format pretty --format html --out reports/
|
1
|
+
default: --require features --no-source --color --format pretty --format html --out reports/testnow_report.html --format json --out reports/testnow_report.json
|
data/data/showtime/env.rb
CHANGED
data/data/showtime/hooks.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
Before do
|
1
|
+
Before do
|
2
2
|
@driver = TestNow.init
|
3
3
|
end
|
4
4
|
|
5
5
|
After do |scenario|
|
6
6
|
if scenario.failed?
|
7
7
|
begin
|
8
|
-
|
9
|
-
embed("#{encoded_img}", "image/png;base64")
|
8
|
+
capture_n_embed
|
10
9
|
rescue
|
11
10
|
p "*** Could not take failed scenario screenshot ***"
|
12
11
|
end
|
@@ -14,23 +13,19 @@ After do |scenario|
|
|
14
13
|
quit_driver
|
15
14
|
end
|
16
15
|
|
17
|
-
at_exit do
|
18
|
-
ENV['TITLE'] = "GITHUB AUTOMATION REPORT" if ENV['TITLE'].nil?
|
19
|
-
report_file = File.absolute_path("github_report.html","reports")
|
20
|
-
doc = File.read(report_file)
|
21
|
-
new_doc = doc.sub("Cucumber Features", "#{ENV['TITLE']}")
|
22
|
-
File.open(report_file, "w") {|file| file.puts new_doc }
|
23
|
-
end
|
24
|
-
|
25
16
|
AfterStep do
|
26
17
|
begin
|
27
|
-
|
28
|
-
embed("#{encoded_img}", "image/png;base64")
|
18
|
+
capture_n_embed
|
29
19
|
rescue
|
30
|
-
|
20
|
+
# Do nothing, screenshot fails in cases of alerts
|
31
21
|
end
|
32
22
|
end
|
33
23
|
|
24
|
+
def capture_n_embed
|
25
|
+
encoded_img = driver.screenshot_as(:base64)
|
26
|
+
embed("#{encoded_img}", "image/png;base64")
|
27
|
+
end
|
28
|
+
|
34
29
|
def driver
|
35
30
|
@driver
|
36
31
|
end
|
@@ -2,15 +2,15 @@ require 'rspec'
|
|
2
2
|
require 'selenium-webdriver'
|
3
3
|
require 'rake'
|
4
4
|
require 'testnow'
|
5
|
+
require 'web-object'
|
5
6
|
|
6
7
|
include RSpec::Matchers
|
7
8
|
include TestNow
|
8
9
|
|
9
|
-
require File.dirname(__FILE__) + "/../pages/
|
10
|
+
require File.dirname(__FILE__) + "/../pages/testnow_page"
|
10
11
|
|
11
12
|
RSpec.configure do |config|
|
12
13
|
config.before(:all) do
|
13
|
-
ENV['TEST_URL'] = "https://github.com" if ENV['TEST_URL'].nil?
|
14
14
|
@driver = TestNow.init
|
15
15
|
end
|
16
16
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: As a TestNow user
|
2
|
+
I want to submit my professional data
|
3
|
+
and verify the acknowledgement
|
4
|
+
|
5
|
+
Scenario: Verify I can submit the testnow form
|
6
|
+
Given I am on the test page
|
7
|
+
When I submit the form
|
8
|
+
Then I verify n accept the validation alert
|
9
|
+
When I fill following data:
|
10
|
+
| Name | Role | Language |
|
11
|
+
| Kaushal Rupani | Automation | Ruby |
|
12
|
+
And I submit the form
|
13
|
+
Then I verify n accept the confirmation box
|
14
|
+
And I verify the acknowledgement
|
@@ -0,0 +1,76 @@
|
|
1
|
+
class TestNowPage < WebObject
|
2
|
+
|
3
|
+
# Different locators such as xpaths, name, css are used in mixed fashion for demo purpose
|
4
|
+
element :header, {:id => 'header'}
|
5
|
+
element :form, {:name => 'testnow-form'}
|
6
|
+
element :name_field, {:id => 'name'}
|
7
|
+
element :automation_radio, {:css => '[value=Automation]'}
|
8
|
+
element :manual_radio, {:css => '[value=Manual]'}
|
9
|
+
element :language_dropdown, {:id => 'lang'}
|
10
|
+
element :terms_checkbox, {:xpath => '//*[@id="terms"]'}
|
11
|
+
element :submit_button, {id: 'button'}
|
12
|
+
|
13
|
+
def visit_page
|
14
|
+
ENV['TEST_URL'] = "http://krupani.github.io/testnow_form" if ENV['TEST_URL'].nil?
|
15
|
+
@driver.get(ENV['TEST_URL'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def verify_n_accept_validation_alert
|
19
|
+
if ENV['BROWSER'].downcase!='phantomjs'
|
20
|
+
alert = @driver.switch_to.alert
|
21
|
+
expect(alert.text).to eq "Please accept terms to submit the data."
|
22
|
+
alert.accept
|
23
|
+
else
|
24
|
+
msg=@driver.execute_script("return window.msg")
|
25
|
+
expect(msg).to eq "Please accept terms to submit the data."
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def fill_form_data(data)
|
30
|
+
data.each do |key,value|
|
31
|
+
case key.downcase
|
32
|
+
when "name"
|
33
|
+
name_field.send_keys(value)
|
34
|
+
when "role"
|
35
|
+
if value.downcase=="automation"
|
36
|
+
automation_radio.click
|
37
|
+
else
|
38
|
+
manual_radio.click
|
39
|
+
end
|
40
|
+
when "language"
|
41
|
+
select = Selenium::WebDriver::Support::Select.new(language_dropdown)
|
42
|
+
select.select_by(:text, value)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
terms_checkbox.click
|
46
|
+
end
|
47
|
+
|
48
|
+
def verify_n_accept_confirmation(expected)
|
49
|
+
if ENV['BROWSER'].downcase!='phantomjs'
|
50
|
+
confirm = @driver.switch_to.alert
|
51
|
+
data = confirm.text
|
52
|
+
expected.values.each do |val|
|
53
|
+
expect(data).to include(val)
|
54
|
+
end
|
55
|
+
confirm.accept
|
56
|
+
else
|
57
|
+
msg=@driver.execute_script("return window.msg")
|
58
|
+
expected.values.each do |val|
|
59
|
+
expect(msg).to include(val)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def submit_form
|
65
|
+
if ENV['BROWSER'].downcase=='phantomjs'
|
66
|
+
@driver.execute_script("window.alert = function(msg){window.msg=msg;return true;};")
|
67
|
+
@driver.execute_script("window.confirm = function(msg){window.msg=msg;return true;};")
|
68
|
+
end
|
69
|
+
submit_button.click
|
70
|
+
end
|
71
|
+
|
72
|
+
def verify_acknowledgement
|
73
|
+
expect(header.text).to eq 'Thank you for using TestNow!!'
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'/../spec_helper')
|
2
|
+
|
3
|
+
describe "As a TestNow user, I want to submit my professional data" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
testnow = TestNowPage.new(@driver)
|
7
|
+
testnow.visit_page
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should display acknowledgement message" do
|
11
|
+
testnow = TestNowPage.new(@driver)
|
12
|
+
testnow.submit_form
|
13
|
+
testnow.verify_n_accept_validation_alert
|
14
|
+
data={'Name'=>'Kaushal Rupani', 'Role'=>'Automation', 'Language'=>'Ruby'}
|
15
|
+
testnow.fill_form_data(data)
|
16
|
+
testnow.submit_form
|
17
|
+
testnow.verify_n_accept_confirmation(data)
|
18
|
+
testnow.verify_acknowledgement
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
Given(/^I am on the test page$/) do
|
3
|
+
testnow = TestNowPage.new(@driver)
|
4
|
+
testnow.visit_page
|
5
|
+
expect(@driver.title).to eq 'Testnow Form'
|
6
|
+
expect(testnow.header.text).to eq 'TestNow Form'
|
7
|
+
end
|
8
|
+
|
9
|
+
When(/^I fill following data:$/) do |table|
|
10
|
+
@data = table.hashes.first
|
11
|
+
testnow = TestNowPage.new(@driver)
|
12
|
+
testnow.fill_form_data(@data)
|
13
|
+
end
|
14
|
+
|
15
|
+
And(/^I submit the form$/) do
|
16
|
+
testnow = TestNowPage.new(@driver)
|
17
|
+
testnow.submit_form
|
18
|
+
end
|
19
|
+
|
20
|
+
Then(/^I verify n accept the validation alert$/) do
|
21
|
+
testnow = TestNowPage.new(@driver)
|
22
|
+
testnow.verify_n_accept_validation_alert
|
23
|
+
end
|
24
|
+
|
25
|
+
Then(/^I verify n accept the confirmation box$/) do
|
26
|
+
testnow = TestNowPage.new(@driver)
|
27
|
+
testnow.verify_n_accept_confirmation(@data)
|
28
|
+
end
|
29
|
+
|
30
|
+
And(/^I verify the acknowledgement$/) do
|
31
|
+
testnow = TestNowPage.new(@driver)
|
32
|
+
testnow.verify_acknowledgement
|
33
|
+
end
|
data/data/showtime/watir/Gemfile
CHANGED
data/data/showtime/watir/env.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
Before do
|
1
|
+
Before do
|
2
2
|
@browser = TestNow.init
|
3
3
|
end
|
4
4
|
|
5
5
|
After do |scenario|
|
6
6
|
if scenario.failed?
|
7
7
|
begin
|
8
|
-
|
9
|
-
embed("#{encoded_img}", "image/png;base64")
|
8
|
+
capture_n_embed
|
10
9
|
rescue
|
11
10
|
p "*** Could not take failed scenario screenshot ***"
|
12
11
|
end
|
@@ -14,23 +13,19 @@ After do |scenario|
|
|
14
13
|
quit_driver
|
15
14
|
end
|
16
15
|
|
17
|
-
at_exit do
|
18
|
-
ENV['TITLE'] = "GITHUB AUTOMATION REPORT" if ENV['TITLE'].nil?
|
19
|
-
report_file = File.absolute_path("github_report.html","reports")
|
20
|
-
doc = File.read(report_file)
|
21
|
-
new_doc = doc.sub("Cucumber Features", "#{ENV['TITLE']}")
|
22
|
-
File.open(report_file, "w") {|file| file.puts new_doc }
|
23
|
-
end
|
24
|
-
|
25
16
|
AfterStep do
|
26
17
|
begin
|
27
|
-
|
28
|
-
embed("#{encoded_img}", "image/png;base64")
|
18
|
+
capture_n_embed
|
29
19
|
rescue
|
30
|
-
|
20
|
+
# Do nothing, screenshot fails in cases of alerts
|
31
21
|
end
|
32
22
|
end
|
33
23
|
|
24
|
+
def capture_n_embed
|
25
|
+
encoded_img = driver.screenshot_as(:base64)
|
26
|
+
embed("#{encoded_img}", "image/png;base64")
|
27
|
+
end
|
28
|
+
|
34
29
|
def driver
|
35
30
|
@browser.driver
|
36
31
|
end
|
@@ -2,16 +2,16 @@ require 'rspec'
|
|
2
2
|
require 'selenium-webdriver'
|
3
3
|
require 'rake'
|
4
4
|
require 'testnow'
|
5
|
-
require 'watir
|
5
|
+
require 'watir'
|
6
|
+
require 'web-object'
|
6
7
|
|
7
8
|
include RSpec::Matchers
|
8
9
|
include TestNow::Watir
|
9
10
|
|
10
|
-
require File.dirname(__FILE__) + "/../pages/
|
11
|
+
require File.dirname(__FILE__) + "/../pages/testnow_page"
|
11
12
|
|
12
13
|
RSpec.configure do |config|
|
13
14
|
config.before(:all) do
|
14
|
-
ENV['TEST_URL'] = "https://github.com" if ENV['TEST_URL'].nil?
|
15
15
|
@browser = TestNow.init
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,80 @@
|
|
1
|
+
class TestNowPage < WebObject
|
2
|
+
|
3
|
+
# Different locators such as xpaths, name, css are used in mixed fashion for demo purpose
|
4
|
+
element :header, {:id => 'header'}
|
5
|
+
element :form, {:name => 'testnow-form'}
|
6
|
+
element :name_field, {:id => 'name'}
|
7
|
+
element :automation_radio, {:css => '[value=Automation]'}
|
8
|
+
element :manual_radio, {:css => '[value=Manual]'}
|
9
|
+
element :language_dropdown, {:id => 'lang'}
|
10
|
+
element :terms_checkbox, {:xpath => '//*[@id="terms"]'}
|
11
|
+
element :submit_button, {id: 'button'}
|
12
|
+
|
13
|
+
def initialize(browser)
|
14
|
+
@browser = browser
|
15
|
+
super(browser.driver)
|
16
|
+
end
|
17
|
+
|
18
|
+
def visit_page
|
19
|
+
ENV['TEST_URL'] = "http://krupani.github.io/testnow_form" if ENV['TEST_URL'].nil?
|
20
|
+
@browser.goto(ENV['TEST_URL'])
|
21
|
+
expect(@browser.title).to eq 'Testnow Form'
|
22
|
+
expect(header.text).to eq 'TestNow Form'
|
23
|
+
end
|
24
|
+
|
25
|
+
def verify_n_accept_validation_alert
|
26
|
+
if ENV['BROWSER'].downcase!='phantomjs'
|
27
|
+
expect(@browser.alert.text).to eq "Please accept terms to submit the data."
|
28
|
+
@browser.alert.ok
|
29
|
+
else
|
30
|
+
msg=@browser.execute_script("return window.msg")
|
31
|
+
expect(msg).to eq "Please accept terms to submit the data."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def fill_form_data(data)
|
36
|
+
data.each do |key,value|
|
37
|
+
case key.downcase
|
38
|
+
when "name"
|
39
|
+
name_field.send_keys(value)
|
40
|
+
when "role"
|
41
|
+
if value.downcase=="automation"
|
42
|
+
automation_radio.click
|
43
|
+
else
|
44
|
+
manual_radio.click
|
45
|
+
end
|
46
|
+
when "language"
|
47
|
+
@browser.select_list(:id,'lang').select(value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
terms_checkbox.click
|
51
|
+
end
|
52
|
+
|
53
|
+
def verify_n_accept_confirmation(expected)
|
54
|
+
if ENV['BROWSER'].downcase!='phantomjs'
|
55
|
+
data = @browser.alert.text
|
56
|
+
expected.values.each do |val|
|
57
|
+
expect(data).to include(val)
|
58
|
+
end
|
59
|
+
@browser.alert.ok
|
60
|
+
else
|
61
|
+
msg=@browser.execute_script("return window.msg")
|
62
|
+
expected.values.each do |val|
|
63
|
+
expect(msg).to include(val)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def submit_form
|
69
|
+
if ENV['BROWSER'].downcase=='phantomjs'
|
70
|
+
@browser.execute_script("window.alert = function(msg){window.msg=msg;return true;};")
|
71
|
+
@browser.execute_script("window.confirm = function(msg){window.msg=msg;return true;};")
|
72
|
+
end
|
73
|
+
submit_button.click
|
74
|
+
end
|
75
|
+
|
76
|
+
def verify_acknowledgement
|
77
|
+
expect(header.text).to eq 'Thank you for using TestNow!!'
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__),'/../spec_helper')
|
2
|
+
|
3
|
+
describe "As a TestNow user, I want to submit my professional data" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
testnow = TestNowPage.new(@browser)
|
7
|
+
testnow.visit_page
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should display acknowledgement message" do
|
11
|
+
testnow = TestNowPage.new(@browser)
|
12
|
+
testnow.submit_form
|
13
|
+
testnow.verify_n_accept_validation_alert
|
14
|
+
data={'Name'=>'Kaushal Rupani', 'Role'=>'Automation', 'Language'=>'Ruby'}
|
15
|
+
testnow.fill_form_data(data)
|
16
|
+
testnow.submit_form
|
17
|
+
testnow.verify_n_accept_confirmation(data)
|
18
|
+
testnow.verify_acknowledgement
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
Given(/^I am on the test page$/) do
|
3
|
+
testnow = TestNowPage.new(@browser)
|
4
|
+
testnow.visit_page
|
5
|
+
end
|
6
|
+
|
7
|
+
When(/^I submit the form$/) do
|
8
|
+
testnow = TestNowPage.new(@browser)
|
9
|
+
testnow.submit_form
|
10
|
+
end
|
11
|
+
|
12
|
+
Then(/^I verify n accept the validation alert$/) do
|
13
|
+
testnow = TestNowPage.new(@browser)
|
14
|
+
testnow.verify_n_accept_validation_alert
|
15
|
+
end
|
16
|
+
|
17
|
+
When(/^I fill following data:$/) do |table|
|
18
|
+
@data = table.hashes.first
|
19
|
+
testnow = TestNowPage.new(@browser)
|
20
|
+
testnow.fill_form_data(@data)
|
21
|
+
end
|
22
|
+
|
23
|
+
Then(/^I verify n accept the confirmation box$/) do
|
24
|
+
testnow = TestNowPage.new(@browser)
|
25
|
+
testnow.verify_n_accept_confirmation(@data)
|
26
|
+
end
|
27
|
+
|
28
|
+
And(/^I verify the acknowledgement$/) do
|
29
|
+
testnow = TestNowPage.new(@browser)
|
30
|
+
testnow.verify_acknowledgement
|
31
|
+
end
|
data/lib/testnow.rb
CHANGED
@@ -5,6 +5,7 @@ require 'testnow/android_chrome'
|
|
5
5
|
require 'testnow/ie'
|
6
6
|
require 'testnow/edge'
|
7
7
|
require 'testnow/firefox_gecko'
|
8
|
+
require 'testnow/phantomjs'
|
8
9
|
|
9
10
|
module TestNow
|
10
11
|
|
@@ -30,8 +31,8 @@ module TestNow
|
|
30
31
|
firefox_gecko = FirefoxGecko.new
|
31
32
|
firefox_gecko.launch_driver_firefox_gecko
|
32
33
|
when "phantomjs"
|
33
|
-
|
34
|
-
|
34
|
+
phantomjs = PhantomJS.new
|
35
|
+
phantomjs.launch_driver_phantomjs
|
35
36
|
when "chromemobile","mobilechrome"
|
36
37
|
chrome = Chrome.new
|
37
38
|
chrome.launch_driver_chrome_mobile
|
@@ -63,6 +64,9 @@ module TestNow
|
|
63
64
|
when "firefoxgecko","geckofirefox","firefoxnew","newfirefox","firefox"
|
64
65
|
firefox_gecko = FirefoxGecko.new
|
65
66
|
firefox_gecko.launch_watir_firefox_gecko
|
67
|
+
when "phantomjs"
|
68
|
+
phantomjs = PhantomJS.new
|
69
|
+
phantomjs.launch_watir_phantomjs
|
66
70
|
when "chromemobile","mobilechrome"
|
67
71
|
chrome = Chrome.new
|
68
72
|
chrome.launch_watir_chrome_mobile
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class PhantomJS
|
2
|
+
|
3
|
+
@private
|
4
|
+
def post_config(driver)
|
5
|
+
driver.manage.timeouts.implicit_wait = 30
|
6
|
+
driver.manage.timeouts.page_load = 120
|
7
|
+
driver.manage.window.maximize
|
8
|
+
end
|
9
|
+
|
10
|
+
def launch_driver_phantomjs
|
11
|
+
driver = Selenium::WebDriver.for(:phantomjs)
|
12
|
+
self.post_config(driver)
|
13
|
+
return driver
|
14
|
+
end
|
15
|
+
|
16
|
+
def launch_watir_phantomjs
|
17
|
+
browser = Watir::Browser.new(:phantomjs)
|
18
|
+
self.post_config(browser.driver)
|
19
|
+
return browser
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/lib/testnow/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testnow
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaushal Rupani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,19 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: watir
|
42
|
+
name: watir
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '6'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '6'
|
55
55
|
description: A gem to configure your WebDriver-Ruby automation framework. Write your
|
56
56
|
tests, leave the browser config to testnow...
|
57
57
|
email: kushrupani@live.com
|
@@ -72,20 +72,20 @@ files:
|
|
72
72
|
- data/showtime/Rakefile_rspec
|
73
73
|
- data/showtime/cucumber.yml
|
74
74
|
- data/showtime/env.rb
|
75
|
-
- data/showtime/github.feature
|
76
|
-
- data/showtime/github_page.rb
|
77
|
-
- data/showtime/github_spec.rb
|
78
|
-
- data/showtime/github_steps.rb
|
79
75
|
- data/showtime/hooks.rb
|
80
76
|
- data/showtime/spec_helper.rb
|
77
|
+
- data/showtime/testnow.feature
|
78
|
+
- data/showtime/testnow_page.rb
|
79
|
+
- data/showtime/testnow_spec.rb
|
80
|
+
- data/showtime/testnow_steps.rb
|
81
81
|
- data/showtime/watir/Gemfile
|
82
82
|
- data/showtime/watir/Gemfile_rspec
|
83
83
|
- data/showtime/watir/env.rb
|
84
|
-
- data/showtime/watir/github_page.rb
|
85
|
-
- data/showtime/watir/github_spec.rb
|
86
|
-
- data/showtime/watir/github_steps.rb
|
87
84
|
- data/showtime/watir/hooks.rb
|
88
85
|
- data/showtime/watir/spec_helper.rb
|
86
|
+
- data/showtime/watir/testnow_page.rb
|
87
|
+
- data/showtime/watir/testnow_spec.rb
|
88
|
+
- data/showtime/watir/testnow_steps.rb
|
89
89
|
- lib/testnow.rb
|
90
90
|
- lib/testnow/android_chrome.rb
|
91
91
|
- lib/testnow/chrome.rb
|
@@ -94,6 +94,7 @@ files:
|
|
94
94
|
- lib/testnow/firefox_gecko.rb
|
95
95
|
- lib/testnow/ie.rb
|
96
96
|
- lib/testnow/opera.rb
|
97
|
+
- lib/testnow/phantomjs.rb
|
97
98
|
- lib/testnow/version
|
98
99
|
- spec/spec_helper.rb
|
99
100
|
- spec/testnow/testnow_spec.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
Feature: As a github user
|
2
|
-
I want to verify my user is searchable on github
|
3
|
-
and confirm my name is displayed correctly on my profile
|
4
|
-
|
5
|
-
Scenario: Verify full name is displayed on facebook public profile
|
6
|
-
Given I am on github page
|
7
|
-
When I search for "Kaushal Rupani" keyword
|
8
|
-
And I follow the Users Tab
|
9
|
-
Then I verify "Kaushal" is displayed
|
10
|
-
When I follow username link to view the profile page
|
11
|
-
Then I verify "Kaushal Rupani" is displayed
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class GithubPage
|
2
|
-
|
3
|
-
def initialize(page_driver)
|
4
|
-
@driver = page_driver
|
5
|
-
end
|
6
|
-
|
7
|
-
def search_github(key)
|
8
|
-
@driver.get(@driver.current_url+"/search?q=#{key}")
|
9
|
-
end
|
10
|
-
|
11
|
-
def click_tab(tab)
|
12
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 30)
|
13
|
-
case tab
|
14
|
-
when "Users"
|
15
|
-
@driver.find_element(:css => "[href*=Users]").click
|
16
|
-
wait.until{@driver.find_element(:id => "user_search_results").displayed?}
|
17
|
-
else
|
18
|
-
puts "Wrong tab buddy!!"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def visit_profile
|
23
|
-
@driver.find_element(:link => "krupani").click
|
24
|
-
end
|
25
|
-
|
26
|
-
def verify_text_presence(word)
|
27
|
-
expect(@driver.find_element(:tag_name => "body").text).to include(word)
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__),'/../spec_helper')
|
2
|
-
|
3
|
-
describe "As a github user, my public profile" do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@driver.get(ENV['TEST_URL'])
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should display my name" do
|
10
|
-
git = GithubPage.new(@driver)
|
11
|
-
git.search_github("Kaushal Rupani")
|
12
|
-
git.click_tab("Users")
|
13
|
-
git.verify_text_presence("Kaushal")
|
14
|
-
git.visit_profile
|
15
|
-
git.verify_text_presence("Kaushal Rupani")
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
Given /^I am on github page$/ do
|
2
|
-
ENV['TEST_URL'] = "https://github.com" if ENV['TEST_URL'].nil?
|
3
|
-
@driver.get(ENV['TEST_URL'])
|
4
|
-
end
|
5
|
-
|
6
|
-
When (/^I search for "([^"]*)" keyword$/) do |key|
|
7
|
-
home = GithubPage.new(@driver)
|
8
|
-
home.search_github(key)
|
9
|
-
end
|
10
|
-
|
11
|
-
When /^I follow the Users Tab$/ do
|
12
|
-
home = GithubPage.new(@driver)
|
13
|
-
home.click_tab("Users")
|
14
|
-
end
|
15
|
-
|
16
|
-
When /^I follow username link to view the profile page$/ do
|
17
|
-
home = GithubPage.new(@driver)
|
18
|
-
home.visit_profile
|
19
|
-
end
|
20
|
-
|
21
|
-
Then (/^I verify "([^"]*)" is displayed$/) do |name|
|
22
|
-
home = GithubPage.new(@driver)
|
23
|
-
home.verify_text_presence(name)
|
24
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class GithubPage
|
2
|
-
|
3
|
-
def initialize(page_browser)
|
4
|
-
@browser = page_browser
|
5
|
-
end
|
6
|
-
|
7
|
-
def search_github(key)
|
8
|
-
@browser.goto(@browser.driver.current_url+"/search?q=#{key}")
|
9
|
-
end
|
10
|
-
|
11
|
-
def click_tab(tab)
|
12
|
-
case tab
|
13
|
-
when "Users"
|
14
|
-
@browser.element(:css => "[href*=Users]").click
|
15
|
-
@browser.element(:id => "user_search_results").wait_until_present(timeout=30)
|
16
|
-
else
|
17
|
-
puts "Wrong tab buddy!!"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def visit_profile
|
22
|
-
@browser.link(:text => "krupani").click
|
23
|
-
end
|
24
|
-
|
25
|
-
def verify_text_presence(word)
|
26
|
-
expect(@browser.element(:text => word).present?).to be true
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__),'/../spec_helper')
|
2
|
-
|
3
|
-
describe "As a github user, my public profile" do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@browser.goto(ENV['TEST_URL'])
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should display my name" do
|
10
|
-
git = GithubPage.new(@browser)
|
11
|
-
git.search_github("Kaushal Rupani")
|
12
|
-
git.click_tab("Users")
|
13
|
-
git.verify_text_presence("Kaushal")
|
14
|
-
git.visit_profile
|
15
|
-
git.verify_text_presence("Kaushal Rupani")
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
Given /^I am on github page$/ do
|
2
|
-
ENV['TEST_URL'] = "https://github.com" if ENV['TEST_URL'].nil?
|
3
|
-
@browser.goto(ENV['TEST_URL'])
|
4
|
-
end
|
5
|
-
|
6
|
-
When (/^I search for "([^"]*)" keyword$/) do |key|
|
7
|
-
home = GithubPage.new(@browser)
|
8
|
-
home.search_github(key)
|
9
|
-
end
|
10
|
-
|
11
|
-
When /^I follow the Users Tab$/ do
|
12
|
-
home = GithubPage.new(@browser)
|
13
|
-
home.click_tab("Users")
|
14
|
-
end
|
15
|
-
|
16
|
-
When /^I follow username link to view the profile page$/ do
|
17
|
-
home = GithubPage.new(@browser)
|
18
|
-
home.visit_profile
|
19
|
-
end
|
20
|
-
|
21
|
-
Then (/^I verify "([^"]*)" is displayed$/) do |name|
|
22
|
-
home = GithubPage.new(@browser)
|
23
|
-
home.verify_text_presence(name)
|
24
|
-
end
|