friendly-cukes 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/DETAILED_DESCRIPTION.md +235 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +22 -0
- data/README.md +108 -0
- data/Rakefile +2 -0
- data/bin/build-extractor +69 -0
- data/bin/friendly-cukes +48 -0
- data/friendly-cukes.gemspec +41 -0
- data/lib/friendly/build_extractor.rb +647 -0
- data/lib/friendly/cukes.rb +29 -0
- data/lib/friendly/cukes/framework/Gemfile +16 -0
- data/lib/friendly/cukes/framework/Gemfile.lock +113 -0
- data/lib/friendly/cukes/framework/Rakefile.rb +19 -0
- data/lib/friendly/cukes/framework/config/config.yml +87 -0
- data/lib/friendly/cukes/framework/config/cucumber.yml +49 -0
- data/lib/friendly/cukes/framework/coverage/.last_run.json +5 -0
- data/lib/friendly/cukes/framework/coverage/.resultset.json +3519 -0
- data/lib/friendly/cukes/framework/coverage/.resultset.json.lock +0 -0
- data/lib/friendly/cukes/framework/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +19 -0
- data/lib/friendly/cukes/framework/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +15 -0
- data/lib/friendly/cukes/framework/coverage/rcov/assets/0.2.3/print.css +12 -0
- data/lib/friendly/cukes/framework/coverage/rcov/assets/0.2.3/rcov.js +42 -0
- data/lib/friendly/cukes/framework/coverage/rcov/assets/0.2.3/screen.css +270 -0
- data/lib/friendly/cukes/framework/coverage/rcov/index.html +392 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-app_init-app_driver_rb.html +98 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-app_utils-data_file_names_rb.html +65 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-app_utils-page_utils_rb.html +533 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-generic-create_log_rb.html +521 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-generic-custom_html_report_rb.html +2522 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-generic-datetime_library_rb.html +296 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-generic-file_library_rb.html +995 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-generic-performance_report_rb.html +1613 -0
- data/lib/friendly/cukes/framework/coverage/rcov/library-generic-read_from_yml_rb.html +944 -0
- data/lib/friendly/cukes/framework/coverage/rcov/object_repository-desktop-gem_search_rb.html +773 -0
- data/lib/friendly/cukes/framework/coverage/rcov/object_repository-desktop-google_search_rb.html +230 -0
- data/lib/friendly/cukes/framework/coverage/rcov/object_repository-mobile-mobile_google_search_rb.html +230 -0
- data/lib/friendly/cukes/framework/coverage/rcov/step_definitions-desktop-gem_search_rb.html +188 -0
- data/lib/friendly/cukes/framework/coverage/rcov/step_definitions-desktop-google_search_steps_rb.html +167 -0
- data/lib/friendly/cukes/framework/coverage/rcov/step_definitions-mobile-mobile_google_search_steps_rb.html +167 -0
- data/lib/friendly/cukes/framework/coverage/rcov/support-browser_settings_rb.html +851 -0
- data/lib/friendly/cukes/framework/coverage/rcov/support-env_rb.html +242 -0
- data/lib/friendly/cukes/framework/coverage/rcov/support-hooks_rb.html +878 -0
- data/lib/friendly/cukes/framework/coverage/rcov/support-html_formatter_rb.html +230 -0
- data/lib/friendly/cukes/framework/features/desktop/google_search/google_search.feature +19 -0
- data/lib/friendly/cukes/framework/features/desktop/rubygems_search/gem_name_tc_04.yml +2 -0
- data/lib/friendly/cukes/framework/features/desktop/rubygems_search/gem_search.feature +37 -0
- data/lib/friendly/cukes/framework/features/desktop/test_data/gem_name.yml +2 -0
- data/lib/friendly/cukes/framework/features/mobile/google_search/mobile_google_search.feature +19 -0
- data/lib/friendly/cukes/framework/library/app_init/app_init.rb +13 -0
- data/lib/friendly/cukes/framework/library/app_utils/data_file_names.rb +2 -0
- data/lib/friendly/cukes/framework/library/app_utils/page_utils.rb +157 -0
- data/lib/friendly/cukes/framework/library/generic/app_logo_1.png +0 -0
- data/lib/friendly/cukes/framework/library/generic/create_log.rb +154 -0
- data/lib/friendly/cukes/framework/library/generic/custom_html_report.rb +852 -0
- data/lib/friendly/cukes/framework/library/generic/datetime_library.rb +79 -0
- data/lib/friendly/cukes/framework/library/generic/file_library.rb +311 -0
- data/lib/friendly/cukes/framework/library/generic/performance_report.rb +518 -0
- data/lib/friendly/cukes/framework/library/generic/read_from_yml.rb +294 -0
- data/lib/friendly/cukes/framework/object_repository/desktop/desktop_web_object_repo.rb +50 -0
- data/lib/friendly/cukes/framework/object_repository/mobile/mobile_web_object_repo.rb +22 -0
- data/lib/friendly/cukes/framework/page_objects/desktop/gem_search.rb +213 -0
- data/lib/friendly/cukes/framework/page_objects/desktop/google_search.rb +53 -0
- data/lib/friendly/cukes/framework/page_objects/mobile/mobile_google_search.rb +53 -0
- data/lib/friendly/cukes/framework/step_definitions/desktop/gem_search.rb +43 -0
- data/lib/friendly/cukes/framework/step_definitions/desktop/google_search_steps.rb +36 -0
- data/lib/friendly/cukes/framework/step_definitions/mobile/mobile_google_search_steps.rb +36 -0
- data/lib/friendly/cukes/framework/support/browser_settings.rb +264 -0
- data/lib/friendly/cukes/framework/support/env.rb +65 -0
- data/lib/friendly/cukes/framework/support/hooks.rb +274 -0
- data/lib/friendly/cukes/framework/support/html_formatter.rb +57 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_33/app_env.log +15 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_33/custom_report/detailed_report/app_logo_1.png +0 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_33/custom_report/detailed_report/desktop_gem_search.html +647 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_33/custom_report/detailed_report/desktop_google_search.html +590 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_33/custom_report/report_home.html +593 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_33/desktop_rubygems_search.log +84 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_33/report_21_05_2015-11_04_54.html +472 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_33/report_21_05_2015-11_04_54.json +299 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_37/app_env.log +15 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_37/desktop_google_search.log +22 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_37/report_21_05_2015-11_03_49.html +472 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-11_03_37/report_21_05_2015-11_03_49.json +155 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-17_28_10/app_env.log +15 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-17_28_10/mobile_google_search.log +22 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-17_28_10/report_21_05_2015-17_29_26.html +472 -0
- data/lib/friendly/cukes/framework/test_result/test_report_21_05_2015-17_28_10/report_21_05_2015-17_29_26.json +143 -0
- data/lib/friendly/cukes/version.rb +61 -0
- metadata +309 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
=begin
|
2
|
+
*Name : Google Search
|
3
|
+
*Description : class that holds the Google page objects and method definitions
|
4
|
+
*Author : Chandra sekaran
|
5
|
+
*Creation Date : 24/04/2015
|
6
|
+
*Modification Date:
|
7
|
+
=end
|
8
|
+
|
9
|
+
module CUKES
|
10
|
+
class Google_HomePage
|
11
|
+
include PageObject
|
12
|
+
include PageUtils
|
13
|
+
include ObjectRepository::OR_DesktopGoogle
|
14
|
+
|
15
|
+
expected_title /Google|bet365/
|
16
|
+
|
17
|
+
# Description : invoked when the page class object is created
|
18
|
+
# Author : Chandra sekaran
|
19
|
+
#
|
20
|
+
def initialize_page
|
21
|
+
wait_for_page_load
|
22
|
+
has_expected_title?
|
23
|
+
end
|
24
|
+
|
25
|
+
# Description : searches for the given input string
|
26
|
+
# Author : Chandra sekaran
|
27
|
+
# Argument :
|
28
|
+
# str_search_text : search text
|
29
|
+
#
|
30
|
+
def search_for_text(str_search_text)
|
31
|
+
wait_for_object(textfield_search_element, "Could not find 'search textbox'")
|
32
|
+
self.textfield_search = str_search_text
|
33
|
+
wait_for_object(textfield_search_element, "Could not find 'search button'")
|
34
|
+
click_on(button_search_element)
|
35
|
+
$log.success("Search completed successfully for string '#{str_search_text}'")
|
36
|
+
rescue Exception => ex
|
37
|
+
$log.error("Failure while searching for string '#{str_search_text}' : #{ex}")
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
# Description : clicks the Bet365.com link from the search result
|
42
|
+
# Author : Chandra sekaran
|
43
|
+
#
|
44
|
+
def click_bet365
|
45
|
+
wait_for_object(link_bet365_element, "Could not find 'bet365.com' link")
|
46
|
+
click_on(link_bet365_element)
|
47
|
+
$log.success("Bet365.com link clicked successfully")
|
48
|
+
rescue Exception => ex
|
49
|
+
$log.error("Failure in clicking the link for Bet365.com : #{ex}")
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
=begin
|
2
|
+
*Name : Google Search
|
3
|
+
*Description : class that holds the Google page objects and method definitions
|
4
|
+
*Author : Chandra sekaran
|
5
|
+
*Creation Date : 24/04/2015
|
6
|
+
*Modification Date:
|
7
|
+
=end
|
8
|
+
|
9
|
+
module CUKES
|
10
|
+
class MobileGoogle_HomePage
|
11
|
+
include PageObject
|
12
|
+
include PageUtils
|
13
|
+
include ObjectRepository::OR_MobileGoogle
|
14
|
+
|
15
|
+
expected_title /Google|RubyGems.org/
|
16
|
+
|
17
|
+
# Description : invoked when the page class object is created
|
18
|
+
# Author : Chandra sekaran
|
19
|
+
#
|
20
|
+
def initialize_page
|
21
|
+
wait_for_page_load
|
22
|
+
has_expected_title?
|
23
|
+
end
|
24
|
+
|
25
|
+
# Description : searches for the given input string
|
26
|
+
# Author : Chandra sekaran
|
27
|
+
# Argument :
|
28
|
+
# str_search_text : search text
|
29
|
+
#
|
30
|
+
def search_for_text(str_search_text)
|
31
|
+
wait_for_object(textfield_search_element, "Could not find 'search textbox'")
|
32
|
+
self.textfield_search = str_search_text
|
33
|
+
wait_for_object(textfield_search_element, "Could not find 'search button'")
|
34
|
+
click_on(button_search_element)
|
35
|
+
$log.success("Search completed successfully for string '#{str_search_text}'")
|
36
|
+
rescue Exception => ex
|
37
|
+
$log.error("Failure while searching for string '#{str_search_text}' : #{ex}")
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
# Description : clicks the Bet365.com link from the search result
|
42
|
+
# Author : Chandra sekaran
|
43
|
+
#
|
44
|
+
def click_rubygems
|
45
|
+
wait_for_object(link_rubygems_element, "Could not find 'rubygems.org' link on mobile")
|
46
|
+
click_on(link_rubygems_element)
|
47
|
+
$log.success("rubygems link clicked successfully")
|
48
|
+
rescue Exception => ex
|
49
|
+
$log.error("Failure in clicking the link for rubygems.org : #{ex}")
|
50
|
+
exit
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Description : step definitions for steps related to Gem search
|
2
|
+
# Author : Chandra sekaran
|
3
|
+
|
4
|
+
# Given the user is on the rubygems.org home page
|
5
|
+
Given /^the user is on the rubygems\.org home page$/ do
|
6
|
+
visit(CUKES::RubyGems)
|
7
|
+
end
|
8
|
+
|
9
|
+
# And the user is signed in
|
10
|
+
And /^the user is signed in$/ do
|
11
|
+
on(CUKES::RubyGems).sign_in
|
12
|
+
end
|
13
|
+
|
14
|
+
# And the user is signed out
|
15
|
+
And /^the user is signed out$/ do
|
16
|
+
visit(CUKES::RubyGems).sign_out
|
17
|
+
end
|
18
|
+
|
19
|
+
# When the user enters "watir" in search textbox and press enter
|
20
|
+
When /^the user enters "(.*?)" in search textbox and press enter$/ do |search_text|
|
21
|
+
on(CUKES::RubyGems).search_for_gem(search_text)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Then the user should be redirected to gem list page of "watir" gem
|
25
|
+
Then /^the user should be redirected to gem list page of "(.*?)" gem$/ do |gem_name|
|
26
|
+
on(CUKES::RubyGems).compare_heading(gem_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
# When the user selects the gem having the maximum downloads
|
30
|
+
When /^the user selects the gem having the maximum downloads$/ do
|
31
|
+
@gem = on(CUKES::RubyGems).fetch_desired_gem
|
32
|
+
$log.success("The gem '#{@gem}' has the maximum downloads")
|
33
|
+
end
|
34
|
+
|
35
|
+
# Then the user should be shown the gem description page
|
36
|
+
Then /^the user should be shown the gem description page$/ do
|
37
|
+
on(CUKES::RubyGems).fetch_gem_details(@gem)
|
38
|
+
end
|
39
|
+
|
40
|
+
# When the user searches for a gem name from test data
|
41
|
+
When /^the user searches for a gem name from test data$/ do
|
42
|
+
on(CUKES::RubyGems).search_for_gem
|
43
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Description : step definitions for steps related to Google search
|
2
|
+
# Author : Chandra sekaran
|
3
|
+
|
4
|
+
# Given the user is on the Google home page
|
5
|
+
Given /^the user is on the Google home page$/ do
|
6
|
+
visit(CUKES::Google_HomePage)
|
7
|
+
end
|
8
|
+
|
9
|
+
# When the user enters "bet365" in the search textbox and clicks the search button
|
10
|
+
When /^the user enters "(.*?)" in the search textbox and clicks the search button$/ do |search_text|
|
11
|
+
on(CUKES::Google_HomePage).search_for_text(search_text)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Then the user should be shown the search results
|
15
|
+
Then /^the user should be shown the search results$/ do
|
16
|
+
on(CUKES::Google_HomePage) do |page|
|
17
|
+
page.wait_until(20, "Could not find 'result div' within 20s") { page.div_result_element.visible? }
|
18
|
+
expect(page.div_result_element.visible?).to be true
|
19
|
+
$log.success("Successfully found search results")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# When the user clicks the link for bet365
|
24
|
+
When /^the user clicks the link for bet(\d+)$/ do |arg1|
|
25
|
+
on(CUKES::Google_HomePage).click_bet365
|
26
|
+
$log.success("Successfully clicked Bet365.com link")
|
27
|
+
end
|
28
|
+
|
29
|
+
# Then the user should be redirected to the bet365.com website
|
30
|
+
Then /^the user should be redirected to the bet(\d+)\.com website$/ do |arg1|
|
31
|
+
on(CUKES::Google_HomePage) do |page|
|
32
|
+
page.wait_for_page_load
|
33
|
+
expect(page.title.include? "bet365 - Sports Betting").to be true
|
34
|
+
$log.success("Successfully redirected to Bet365.com page")
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Description : step definitions for steps related to Google search
|
2
|
+
# Author : Chandra sekaran
|
3
|
+
|
4
|
+
# Given the user is on the Google home page
|
5
|
+
Given /^the user is on the mobile Google home page$/ do
|
6
|
+
visit(CUKES::MobileGoogle_HomePage)
|
7
|
+
end
|
8
|
+
|
9
|
+
# When the user enters "bet365" in the search textbox and clicks the search button
|
10
|
+
When /^the user searches for "(.*?)"$/ do |search_text|
|
11
|
+
on(CUKES::MobileGoogle_HomePage).search_for_text(search_text)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Then the user should be shown the search results
|
15
|
+
Then /^the user should be shown search results$/ do
|
16
|
+
on(CUKES::MobileGoogle_HomePage) do |page|
|
17
|
+
page.wait_for_object(page.div_result_element, "Could not find 'result div'")
|
18
|
+
expect(page.div_result_element.visible?).to be true
|
19
|
+
$log.success("Successfully found search results")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# When the user clicks the link for bet365
|
24
|
+
When /^the user clicks the link for mobile rubygems$/ do
|
25
|
+
on(CUKES::MobileGoogle_HomePage).click_rubygems
|
26
|
+
$log.success("Successfully clicked rubygems.org link")
|
27
|
+
end
|
28
|
+
|
29
|
+
# Then the user should be redirected to the bet365.com website
|
30
|
+
Then /^the user should be redirected to the mobile rubygems.org website$/ do
|
31
|
+
on(CUKES::MobileGoogle_HomePage) do |page|
|
32
|
+
page.wait_for_page_load
|
33
|
+
expect(page.title.include? "RubyGems.org").to be true
|
34
|
+
$log.success("Successfully redirected to rubygems.org page")
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,264 @@
|
|
1
|
+
=begin
|
2
|
+
*Name : BrowserSettings
|
3
|
+
*Description : Browser settings definition for different web and mobile browsers
|
4
|
+
*Author : Chandra sekaran
|
5
|
+
*Creation Date : 24/04/2015
|
6
|
+
*Updation Date :
|
7
|
+
=end
|
8
|
+
|
9
|
+
module CUKES
|
10
|
+
module BrowserSettings
|
11
|
+
include FileLibrary # module that defines all file related manipulations
|
12
|
+
include DateTimeLibrary # module that defines all date time manipulations
|
13
|
+
|
14
|
+
# Description : launches a browser and returns the browser object
|
15
|
+
# Author : Chandra sekaran
|
16
|
+
# Arguments :
|
17
|
+
# str_browser_name: name of the browser
|
18
|
+
# Return values :
|
19
|
+
# @browser : browser object
|
20
|
+
#
|
21
|
+
def self.browser_setup(str_browser_name)
|
22
|
+
@browser_name = str_browser_name
|
23
|
+
@browser = start_browser(@browser_name)
|
24
|
+
raise "Nil class error : No valid browser object found for #{str_browser_name}" if @browser.nil?
|
25
|
+
return @browser
|
26
|
+
rescue Exception => ex
|
27
|
+
$log.error("Error in launching browser #{str_browser_name} : #{ex}")
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
# Description : deletes all cookies from the current browser
|
32
|
+
# Author : Chandra sekaran
|
33
|
+
#
|
34
|
+
def self.delete_cookies
|
35
|
+
@browser.manage.delete_all_cookies
|
36
|
+
$log.success("#{@browser_name} browser cookies deleted successfully")
|
37
|
+
rescue Exception => ex
|
38
|
+
$log.error("Error while deleting the " + @browser_name + " browser cookies - #{ex}")
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
# Description : launches the given URL in the current browser
|
43
|
+
# Author : Chandra sekaran
|
44
|
+
# Arguments :
|
45
|
+
# str_url : url of the web site to be launched
|
46
|
+
#
|
47
|
+
def self.launch_url(str_url)
|
48
|
+
# delete_cookies
|
49
|
+
@browser.navigate.to(str_url)
|
50
|
+
$log.info("#{str_url} launched successfully")
|
51
|
+
rescue Exception => ex
|
52
|
+
$log.error("Error in launching URL - #{str_url}")
|
53
|
+
exit
|
54
|
+
end
|
55
|
+
|
56
|
+
# Description : sets the timeout limit to find elements
|
57
|
+
# Author : Chandra sekaran
|
58
|
+
# Arguments :
|
59
|
+
# num_timeout : numeric timeout value
|
60
|
+
#
|
61
|
+
def self.set_timeout(num_timeout)
|
62
|
+
@browser.manage.timeouts.implicit_wait = num_timeout
|
63
|
+
$log.success("Selenium timeout set to " + num_timeout.to_s)
|
64
|
+
rescue Exception => ex
|
65
|
+
$log.error("Error in setting the selenium timeout to: " + num_timeout.to_s)
|
66
|
+
exit
|
67
|
+
end
|
68
|
+
|
69
|
+
# Description : starts the browser and returns the browser object
|
70
|
+
# Author : Chandra sekaran
|
71
|
+
# Arguments :
|
72
|
+
# str_browser : browser name
|
73
|
+
# Return values :
|
74
|
+
# @browser : browser object of the launched browser
|
75
|
+
#
|
76
|
+
def self.start_browser(str_browser)
|
77
|
+
@browser = ''
|
78
|
+
if PLATFORM == "desktop"
|
79
|
+
@browser = setup_desktop_browser(str_browser)
|
80
|
+
@browser.manage.window.maximize if !@browser.nil?
|
81
|
+
else
|
82
|
+
@browser = setup_mobile_browser
|
83
|
+
end
|
84
|
+
return @browser
|
85
|
+
end
|
86
|
+
|
87
|
+
# Description : closes the current browser
|
88
|
+
# Author : Chandra sekaran
|
89
|
+
#
|
90
|
+
def self.close_browser
|
91
|
+
@browser.close
|
92
|
+
$log.success("Current browser closed successfully")
|
93
|
+
$log_env.success("Current browser closed successfully")
|
94
|
+
rescue Exception => ex
|
95
|
+
$log.error("Error while closing the current browser - #{ex}")
|
96
|
+
exit
|
97
|
+
end
|
98
|
+
|
99
|
+
# Description : closes the current browser
|
100
|
+
# Author : Chandra sekaran
|
101
|
+
#
|
102
|
+
def self.quit_browser
|
103
|
+
@browser.quit
|
104
|
+
$log_env.success("Current browser closed successfully")
|
105
|
+
rescue Exception => ex
|
106
|
+
$log.error("Error while closing the current browser - #{ex}")
|
107
|
+
exit
|
108
|
+
end
|
109
|
+
|
110
|
+
# Description : restarts the current browser
|
111
|
+
# Author : Chandra sekaran
|
112
|
+
# Return value :
|
113
|
+
# @browser : browser object of the new browser
|
114
|
+
#
|
115
|
+
def self.restart_browser
|
116
|
+
quit_browser
|
117
|
+
@browser_name = BROWSER
|
118
|
+
$log.info("Restarting the browser (#{@browser_name})")
|
119
|
+
@browser = browser_setup(@browser_name)
|
120
|
+
@browser
|
121
|
+
rescue Exception => ex
|
122
|
+
$log.error("Error while restarting browser - #{ex}")
|
123
|
+
exit
|
124
|
+
end
|
125
|
+
|
126
|
+
# Description : launches the desktop browser
|
127
|
+
# Author : Chandra sekaran
|
128
|
+
# Arguments :
|
129
|
+
# str_browser : browser name
|
130
|
+
# Return value :
|
131
|
+
# @browser : browser object of the new browser
|
132
|
+
#
|
133
|
+
def self.setup_desktop_browser(str_browser)
|
134
|
+
@browser = nil
|
135
|
+
case str_browser.downcase
|
136
|
+
when "internet_explorer"
|
137
|
+
@browser = Selenium::WebDriver.for :internet_explorer
|
138
|
+
|
139
|
+
when "firefox"
|
140
|
+
@browser = Selenium::WebDriver.for :firefox
|
141
|
+
|
142
|
+
when "chrome"
|
143
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => ["test-type"]})
|
144
|
+
@browser = Selenium::WebDriver.for :chrome, desired_capabilities: caps
|
145
|
+
|
146
|
+
# if you want to set the download path to your local framework directory, then you can use the below
|
147
|
+
# selenium capabilities, which will set the current download directory to your current test result directory
|
148
|
+
#caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => {"args" => ["test-type" ]})
|
149
|
+
#prefs = {
|
150
|
+
# :download => {
|
151
|
+
# :prompt_for_download => false,
|
152
|
+
# :default_directory => File.expand_path($current_log_dir)
|
153
|
+
# }
|
154
|
+
#}
|
155
|
+
#@browser = Selenium::WebDriver.for :chrome, :prefs => prefs, desired_capabilities: caps
|
156
|
+
|
157
|
+
when "safari"
|
158
|
+
@browser = Selenium::WebDriver.for :safari
|
159
|
+
|
160
|
+
when "ios"
|
161
|
+
if RUBY_PLATFORM.downcase.include?("darwin")
|
162
|
+
@browser = Selenium::WebDriver.for :iphone
|
163
|
+
else
|
164
|
+
raise "You can't run IOS tests on non-mac machine"
|
165
|
+
end
|
166
|
+
else
|
167
|
+
raise "Could not determine the browser - #{str_browser}"
|
168
|
+
end
|
169
|
+
$log.success("Successfully launched desktop #{str_browser} browser (Version : #{@browser.capabilities[:version]}, Resolution : '#{@browser.execute_script('return screen.width')}x#{@browser.execute_script('return screen.height')}')")
|
170
|
+
return @browser
|
171
|
+
rescue Exception => ex
|
172
|
+
$log.error("Error in starting desktop browser #{str_browser} : " + ex)
|
173
|
+
exit
|
174
|
+
end
|
175
|
+
|
176
|
+
# Description : saves the screenshot of the webpage as png file
|
177
|
+
# Author : Chandra sekaran
|
178
|
+
# Arguments :
|
179
|
+
# str_module_name : module name under features directory
|
180
|
+
#
|
181
|
+
def self.capture_screenshot(str_module_name)
|
182
|
+
str_imgdir_path = "#{$current_log_dir}/screenshot"
|
183
|
+
unless File.directory?(str_imgdir_path) # creates a new directory
|
184
|
+
FileUtils.mkdir_p(str_imgdir_path)
|
185
|
+
end
|
186
|
+
str_image = "/#{str_module_name}_#{Time.now.strftime(DATETIME_FORMAT)}.png"
|
187
|
+
str_imgdir_path << str_image # adds image file name to the directory
|
188
|
+
@browser.save_screenshot(str_imgdir_path) # saves the screenshot image to the directory
|
189
|
+
$log.info("Screenshot is saved in #{str_imgdir_path}")
|
190
|
+
return "screenshot#{str_image}"
|
191
|
+
rescue Exception => ex
|
192
|
+
$log.error("Error in taking screenshot for #{str_imgdir_path} : #{ex}")
|
193
|
+
exit
|
194
|
+
end
|
195
|
+
|
196
|
+
# Description : launches the mobile browser
|
197
|
+
# Author : Chandra sekaran
|
198
|
+
# Arguments :
|
199
|
+
# @browser : browser object of the mobile browser
|
200
|
+
#
|
201
|
+
def self.setup_mobile_browser
|
202
|
+
bool_device_enabled = DEVICE.nil? ? false : (DEVICE.downcase.eql?("true")? true : false)
|
203
|
+
case(BROWSER.downcase)
|
204
|
+
when "android", "chrome", "browser"
|
205
|
+
@browser = setup_android(bool_device_enabled, BROWSER)
|
206
|
+
when "safari"
|
207
|
+
if is_emulator_enabled
|
208
|
+
caps = {
|
209
|
+
:platform => 'Mac',
|
210
|
+
:device => 'iPhone Simulator',
|
211
|
+
:browser_name => 'iOS',
|
212
|
+
:version => '7.1',
|
213
|
+
:app => 'safari',
|
214
|
+
:newCommandTimeout => 60000,
|
215
|
+
:javascript_enabled => true
|
216
|
+
}
|
217
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
218
|
+
client.timeout = 1000 # seconds
|
219
|
+
@browser = Selenium::WebDriver.for :remote, :url => app_url , :desired_capabilities => caps , :http_client => client
|
220
|
+
end
|
221
|
+
else
|
222
|
+
raise "Invalid browser name : #{BROWSER}"
|
223
|
+
end
|
224
|
+
return @browser
|
225
|
+
rescue Exception => ex
|
226
|
+
$log.error("Error while setting up mobile browser : #{ex}")
|
227
|
+
exit
|
228
|
+
end
|
229
|
+
|
230
|
+
# Description : launches mobile browser
|
231
|
+
# Author : Chandra sekaran
|
232
|
+
# Arguments :
|
233
|
+
# str_module_name : module name under features directory
|
234
|
+
#
|
235
|
+
def self.setup_android(bool_device_enabled, str_browser_name)
|
236
|
+
browser = ""
|
237
|
+
if str_browser_name.downcase == "chrome"
|
238
|
+
browser_name = "Chrome"
|
239
|
+
elsif str_browser_name.downcase == "browser" || str_browser_name.downcase == "android"
|
240
|
+
browser_name = "Browser"
|
241
|
+
else
|
242
|
+
raise "Profile for '#{str_browser_name}' browser does not exists"
|
243
|
+
end
|
244
|
+
|
245
|
+
if bool_device_enabled
|
246
|
+
caps = { :browserName => browser_name, :platformName => "Android", :newCommandTimeout => 60000, :deviceName => "4D00C0124B174161" }
|
247
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
248
|
+
client.timeout = 5000
|
249
|
+
browser = Selenium::WebDriver.for(:remote, :url => "http://localhost:4723/wd/hub/", :http_client => client, :desired_capabilities => caps)
|
250
|
+
else
|
251
|
+
caps = { :browserName => browser_name, :platformName => "Android", :Version => "4.4.2", :deviceName => "EMULATOR-5554" }
|
252
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
253
|
+
client.timeout = 5000
|
254
|
+
browser = Selenium::WebDriver.for(:remote, :url => "http://localhost:4723/wd/hub/", :http_client => client, :desired_capabilities => caps)
|
255
|
+
end
|
256
|
+
$log.success("Launched #{str_browser_name} in Android #{bool_device_enabled ? 'device' : 'emulator'} successfully")
|
257
|
+
browser
|
258
|
+
rescue Exception => ex
|
259
|
+
$log.error("Error while setting Android browser profile for '#{str_browser_name}' : #{ex}")
|
260
|
+
exit
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|
264
|
+
end
|