testnow 0.0.9 → 0.1.0

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
data/lib/testnow.rb CHANGED
@@ -1,72 +1,79 @@
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
-
9
- module TestNow
10
-
11
- def init
12
- ENV['BROWSER'] = "firefox" if ENV['BROWSER'].nil?
13
- case ENV['BROWSER'].downcase
14
- when "chrome"
15
- chrome = Chrome.new
16
- chrome.launch_driver_chrome
17
- when "android"
18
- puts "Coming Soon!!\n"
19
- puts "Apologies for inconvenience...\n\n"
20
- when "opera"
21
- opera = Opera.new
22
- opera.launch_driver_opera
23
- when "androidchrome"
24
- ac = AndroidChrome.new
25
- ac.launch_driver_android_chrome
26
- when "ie"
27
- ie = IE.new
28
- ie.launch_driver_ie
29
- when "edge"
30
- edge = MicrosoftEdge.new
31
- edge.launch_driver_edge
32
- when "phantomjs"
33
- puts "Coming Soon!!\n"
34
- puts "Apologies for inconvenience...\n\n"
35
- else
36
- ff = Firefox.new
37
- ff.launch_driver_firefox
38
- end
39
- end
40
-
41
- module Watir
42
- def init
43
- ENV['BROWSER'] = "firefox" if ENV['BROWSER'].nil?
44
- case ENV['BROWSER'].downcase
45
- when "chrome"
46
- chrome = Chrome.new
47
- chrome.launch_watir_chrome
48
- when "android"
49
- puts "Coming Soon!!\n"
50
- puts "Apologies for inconvenience...\n\n"
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
- else
64
- ff = Firefox.new
65
- ff.launch_watir_firefox
66
- end
67
- end
68
- end
69
-
70
- end
71
-
72
-
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,8 +1,8 @@
1
- module TestNow
2
-
3
- def launch_driver_android
4
- @driver = Selenium::WebDriver.for :remote, :desired_capabilities => :android
5
- @driver
6
- end
7
-
1
+ module TestNow
2
+
3
+ def launch_driver_android
4
+ @driver = Selenium::WebDriver.for :remote, :desired_capabilities => :android
5
+ @driver
6
+ end
7
+
8
8
  end
@@ -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,23 @@
1
- class Chrome
2
-
3
- @private
4
- def post_chrome_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_chrome_config(driver)
14
- return driver
15
- end
16
-
17
- def launch_watir_chrome
18
- browser = Watir::Browser.new :chrome
19
- self.post_chrome_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
23
  end