testnow 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,18 +1,18 @@
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
-
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
18
  end
@@ -1,24 +1,24 @@
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)
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
24
  end
@@ -1,40 +1,40 @@
1
- Before do |scenario|
2
- @browser = TestNow.init
3
- end
4
-
5
- After do |scenario|
6
- if scenario.failed?
7
- begin
8
- encoded_img = driver.screenshot_as(:base64)
9
- embed("#{encoded_img}", "image/png;base64")
10
- rescue
11
- p "*** Could not take failed scenario screenshot ***"
12
- end
13
- end
14
- quit_driver
15
- end
16
-
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
- AfterStep do
26
- begin
27
- encoded_img = driver.screenshot_as(:base64)
28
- embed("#{encoded_img}", "image/png;base64")
29
- rescue
30
- p "*** Could Not take screenshot ***"
31
- end
32
- end
33
-
34
- def driver
35
- @browser.driver
36
- end
37
-
38
- def quit_driver
39
- @browser.quit
1
+ Before do |scenario|
2
+ @browser = TestNow.init
3
+ end
4
+
5
+ After do |scenario|
6
+ if scenario.failed?
7
+ begin
8
+ encoded_img = driver.screenshot_as(:base64)
9
+ embed("#{encoded_img}", "image/png;base64")
10
+ rescue
11
+ p "*** Could not take failed scenario screenshot ***"
12
+ end
13
+ end
14
+ quit_driver
15
+ end
16
+
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
+ AfterStep do
26
+ begin
27
+ encoded_img = driver.screenshot_as(:base64)
28
+ embed("#{encoded_img}", "image/png;base64")
29
+ rescue
30
+ p "*** Could Not take screenshot ***"
31
+ end
32
+ end
33
+
34
+ def driver
35
+ @browser.driver
36
+ end
37
+
38
+ def quit_driver
39
+ @browser.quit
40
40
  end
@@ -1,21 +1,21 @@
1
- require 'rspec'
2
- require 'selenium-webdriver'
3
- require 'rake'
4
- require 'testnow'
5
- require 'watir-webdriver'
6
-
7
- include RSpec::Matchers
8
- include TestNow::Watir
9
-
10
- require File.dirname(__FILE__) + "/../pages/github_page"
11
-
12
- RSpec.configure do |config|
13
- config.before(:all) do
14
- ENV['TEST_URL'] = "https://github.com" if ENV['TEST_URL'].nil?
15
- @browser = TestNow.init
16
- end
17
-
18
- config.after(:all) do
19
- @browser.quit
20
- end
21
- end
1
+ require 'rspec'
2
+ require 'selenium-webdriver'
3
+ require 'rake'
4
+ require 'testnow'
5
+ require 'watir-webdriver'
6
+
7
+ include RSpec::Matchers
8
+ include TestNow::Watir
9
+
10
+ require File.dirname(__FILE__) + "/../pages/github_page"
11
+
12
+ RSpec.configure do |config|
13
+ config.before(:all) do
14
+ ENV['TEST_URL'] = "https://github.com" if ENV['TEST_URL'].nil?
15
+ @browser = TestNow.init
16
+ end
17
+
18
+ config.after(:all) do
19
+ @browser.quit
20
+ end
21
+ end
@@ -1,79 +1,78 @@
1
- require 'testnow/chrome'
2
- require 'testnow/opera'
3
- require 'testnow/firefox'
4
- require 'testnow/android'
5
- require 'testnow/android_chrome'
6
- require 'testnow/ie'
7
- require 'testnow/edge'
8
- require 'testnow/firefox_gecko'
9
-
10
- module TestNow
11
-
12
- def init
13
- ENV['BROWSER'] = "firefox" if ENV['BROWSER'].nil?
14
- case ENV['BROWSER'].downcase.gsub(" ","").gsub("_","")
15
- when "chrome"
16
- chrome = Chrome.new
17
- chrome.launch_driver_chrome
18
- when "android"
19
- puts "Coming Soon!!\n"
20
- puts "Apologies for inconvenience...\n\n"
21
- when "opera"
22
- opera = Opera.new
23
- opera.launch_driver_opera
24
- when "androidchrome","chromeandroid"
25
- ac = AndroidChrome.new
26
- ac.launch_driver_android_chrome
27
- when "ie"
28
- ie = IE.new
29
- ie.launch_driver_ie
30
- when "edge"
31
- edge = MicrosoftEdge.new
32
- edge.launch_driver_edge
33
- when "firefoxgecko","geckofirefox","firefoxnew","newfirefox"
34
- firefox_gecko = FirefoxGecko.new
35
- firefox_gecko.launch_driver_firefox_gecko
36
- when "phantomjs"
37
- puts "Coming Soon!!\n"
38
- puts "Apologies for inconvenience...\n\n"
39
- else
40
- ff = Firefox.new
41
- ff.launch_driver_firefox
42
- end
43
- end
44
-
45
- module Watir
46
- def init
47
- ENV['BROWSER'] = "firefox" if ENV['BROWSER'].nil?
48
- case ENV['BROWSER'].downcase
49
- when "chrome"
50
- chrome = Chrome.new
51
- chrome.launch_watir_chrome
52
- when "android"
53
- puts "Coming Soon!!\n"
54
- puts "Apologies for inconvenience...\n\n"
55
- when "opera"
56
- opera = Opera.new
57
- opera.launch_watir_opera
58
- when "androidchrome"
59
- ac = AndroidChrome.new
60
- ac.launch_watir_android_chrome
61
- when "ie"
62
- ie = IE.new
63
- ie.launch_watir_ie
64
- when "edge"
65
- edge = MicrosoftEdge.new
66
- edge.launch_watir_edge
67
- when "firefoxgecko","geckofirefox","firefoxnew","newfirefox"
68
- firefox_gecko = FirefoxGecko.new
69
- firefox_gecko.launch_watir_firefox_gecko
70
- else
71
- ff = Firefox.new
72
- ff.launch_watir_firefox
73
- end
74
- end
75
- end
76
-
77
- end
78
-
79
-
1
+ require 'testnow/chrome'
2
+ require 'testnow/opera'
3
+ require 'testnow/firefox'
4
+ require 'testnow/android_chrome'
5
+ require 'testnow/ie'
6
+ require 'testnow/edge'
7
+ require 'testnow/firefox_gecko'
8
+
9
+ module TestNow
10
+
11
+ def init
12
+ ENV['BROWSER'] = "firefox" if ENV['BROWSER'].nil?
13
+ case ENV['BROWSER'].downcase.gsub(" ","").gsub("_","")
14
+ when "chrome"
15
+ chrome = Chrome.new
16
+ chrome.launch_driver_chrome
17
+ when "opera"
18
+ opera = Opera.new
19
+ opera.launch_driver_opera
20
+ when "androidchrome","chromeandroid"
21
+ ac = AndroidChrome.new
22
+ ac.launch_driver_android_chrome
23
+ when "ie"
24
+ ie = IE.new
25
+ ie.launch_driver_ie
26
+ when "edge"
27
+ edge = MicrosoftEdge.new
28
+ edge.launch_driver_edge
29
+ when "firefoxgecko","geckofirefox","firefoxnew","newfirefox","firefox"
30
+ firefox_gecko = FirefoxGecko.new
31
+ firefox_gecko.launch_driver_firefox_gecko
32
+ when "phantomjs"
33
+ puts "Coming Soon!!\n"
34
+ puts "Apologies for inconvenience...\n\n"
35
+ when "chromemobile","mobilechrome"
36
+ chrome = Chrome.new
37
+ chrome.launch_driver_chrome_mobile
38
+ when "firefoxold","oldfirefox"
39
+ ff = Firefox.new
40
+ ff.launch_driver_firefox
41
+ end
42
+ end
43
+
44
+ module Watir
45
+ def init
46
+ ENV['BROWSER'] = "firefox" if ENV['BROWSER'].nil?
47
+ case ENV['BROWSER'].downcase
48
+ when "chrome"
49
+ chrome = Chrome.new
50
+ chrome.launch_watir_chrome
51
+ when "opera"
52
+ opera = Opera.new
53
+ opera.launch_watir_opera
54
+ when "androidchrome"
55
+ ac = AndroidChrome.new
56
+ ac.launch_watir_android_chrome
57
+ when "ie"
58
+ ie = IE.new
59
+ ie.launch_watir_ie
60
+ when "edge"
61
+ edge = MicrosoftEdge.new
62
+ edge.launch_watir_edge
63
+ when "firefoxgecko","geckofirefox","firefoxnew","newfirefox","firefox"
64
+ firefox_gecko = FirefoxGecko.new
65
+ firefox_gecko.launch_watir_firefox_gecko
66
+ when "chromemobile","mobilechrome"
67
+ chrome = Chrome.new
68
+ chrome.launch_watir_chrome_mobile
69
+ when "firefoxold","oldfirefox"
70
+ ff = Firefox.new
71
+ ff.launch_watir_firefox
72
+ end
73
+ end
74
+ end
75
+
76
+ end
77
+
78
+
@@ -1,27 +1,27 @@
1
- class AndroidChrome
2
-
3
- @private
4
- def android_chrome_config
5
- @client = Selenium::WebDriver::Remote::Http::Default.new
6
- @client.timeout = 120
7
- @service = Selenium::WebDriver::Chrome::Service.new("/usr/local/bin/chromedriver")
8
- @service.start
9
- end
10
-
11
- def launch_driver_android_chrome
12
- self.android_chrome_config
13
- caps = {'chromeOptions'=> {'androidPackage' => 'com.android.chrome'}}
14
- driver = Selenium::WebDriver.for(:remote, :http_client => client, :url => service.uri, :desired_capabilities => caps)
15
- driver.manage.timeouts.implicit_wait = 60
16
- return driver
17
- end
18
-
19
- def launch_watir_android_chrome
20
- self.android_chrome_config
21
- caps = {'chromeOptions'=> {'androidPackage' => 'com.android.chrome'}}
22
- browser = Watir::Browser.new(:remote, :url => @service.uri, :desired_capabilities => @cap, :http_client => @client)
23
- browser.driver.manage.timeouts.implicit_wait = 60
24
- return browser
25
- end
26
-
1
+ class AndroidChrome
2
+
3
+ @private
4
+ def android_chrome_config
5
+ @client = Selenium::WebDriver::Remote::Http::Default.new
6
+ @client.timeout = 120
7
+ @service = Selenium::WebDriver::Chrome::Service.new("/usr/local/bin/chromedriver")
8
+ @service.start
9
+ end
10
+
11
+ def launch_driver_android_chrome
12
+ self.android_chrome_config
13
+ caps = {'chromeOptions'=> {'androidPackage' => 'com.android.chrome'}}
14
+ driver = Selenium::WebDriver.for(:remote, :http_client => client, :url => service.uri, :desired_capabilities => caps)
15
+ driver.manage.timeouts.implicit_wait = 60
16
+ return driver
17
+ end
18
+
19
+ def launch_watir_android_chrome
20
+ self.android_chrome_config
21
+ caps = {'chromeOptions'=> {'androidPackage' => 'com.android.chrome'}}
22
+ browser = Watir::Browser.new(:remote, :url => @service.uri, :desired_capabilities => @cap, :http_client => @client)
23
+ browser.driver.manage.timeouts.implicit_wait = 60
24
+ return browser
25
+ end
26
+
27
27
  end
@@ -1,23 +1,48 @@
1
- class Chrome
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
- # Chrome Browser
11
- def launch_driver_chrome
12
- driver = Selenium::WebDriver.for :chrome
13
- self.post_config(driver)
14
- return driver
15
- end
16
-
17
- def launch_watir_chrome
18
- browser = Watir::Browser.new :chrome
19
- self.post_config(browser.driver)
20
- return browser
21
- end
22
-
1
+ class Chrome
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
+ # Chrome Browser
11
+ def launch_driver_chrome
12
+ driver = Selenium::WebDriver.for :chrome
13
+ self.post_config(driver)
14
+ return driver
15
+ end
16
+
17
+ def launch_watir_chrome
18
+ browser = Watir::Browser.new :chrome
19
+ self.post_config(browser.driver)
20
+ return browser
21
+ end
22
+
23
+ @private
24
+ def pre_mobile_chrome_config
25
+ device_name = ENV['DEVICE'].gsub("_"," ")
26
+ mobile_emulation = { "deviceName" => device_name }
27
+ caps = Selenium::WebDriver::Remote::Capabilities.chrome(
28
+ "chromeOptions" => { "mobileEmulation" => mobile_emulation })
29
+ return caps
30
+ end
31
+
32
+ def launch_driver_chrome_mobile
33
+ caps = self.pre_mobile_chrome_config
34
+ driver = Selenium::WebDriver.for(:chrome,
35
+ :desired_capabilities => caps)
36
+ self.post_config(driver)
37
+ return driver
38
+ end
39
+
40
+ def launch_watir_chrome_mobile
41
+ caps = self.pre_mobile_chrome_config
42
+ browser = Watir::Browser.new(:chrome,
43
+ :desired_capabilities => caps)
44
+ self.post_config(browser.driver)
45
+ return browser
46
+ end
47
+
23
48
  end