robotest 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: cd392de1a562f67f155ce7619bc89a55298d1304e31b579acd27dac9f1566be9
4
+ data.tar.gz: cbad2a416a4827362da5a6922d2c00ffd1d63bbd46345877e4d9e29507ca5981
5
+ SHA512:
6
+ metadata.gz: 64f9d1454edb569d0b796cddf4ad17ea1c58c290abee9e73ea4f4fe19b4861ccb10b861cb6f13d51da5dd7382db4f41f2a16812faffb23fc52a85f164dcf8b02
7
+ data.tar.gz: 8f5165f6531a6d5bb61d5b9e08fbb2d086f67d3629af7c0adfa3dace3c40bad1c248878d4da6db4d510e13b0292060d17ec5898ed3fa8728c7910e5be70e70f3
@@ -0,0 +1,93 @@
1
+ # Contributing
2
+
3
+ When contributing to this repository, please first discuss the change you wish to make via issue,
4
+ email, or any other method with the owners of this repository before making a change.
5
+
6
+ Please note we have a code of conduct, please follow it in all your interactions with the project.
7
+
8
+ ## Pull Request Process
9
+
10
+ 1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11
+ build.
12
+ 2. Update the README.md with details of changes to the interface, this includes new environment
13
+ variables, exposed ports, useful file locations and container parameters.
14
+ 3. Increase the version numbers in any examples files and the README.md to the new version that this
15
+ Pull Request would represent.
16
+ 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17
+ do not have permission to do that, you may request the second reviewer to merge it for you.
18
+
19
+ ## Code of Conduct
20
+
21
+ ### Our Pledge
22
+
23
+ In the interest of fostering an open and welcoming environment, we as
24
+ contributors and maintainers pledge to making participation in our project and
25
+ our community a harassment-free experience for everyone, regardless of age, body
26
+ size, disability, ethnicity, gender identity and expression, level of experience,
27
+ nationality, personal appearance, race, religion, or sexual identity and
28
+ orientation.
29
+
30
+ ### Our Standards
31
+
32
+ Examples of behavior that contributes to creating a positive environment
33
+ include:
34
+
35
+ * Using welcoming and inclusive language
36
+ * Being respectful of differing viewpoints and experiences
37
+ * Gracefully accepting constructive criticism
38
+ * Focusing on what is best for the community
39
+ * Showing empathy towards other community members
40
+
41
+ Examples of unacceptable behavior by participants include:
42
+
43
+ * The use of sexualized language or imagery and unwelcome sexual attention or
44
+ advances
45
+ * Trolling, insulting/derogatory comments, and personal or political attacks
46
+ * Public or private harassment
47
+ * Publishing others' private information, such as a physical or electronic
48
+ address, without explicit permission
49
+ * Other conduct which could reasonably be considered inappropriate in a
50
+ professional setting
51
+
52
+ ### Our Responsibilities
53
+
54
+ Project maintainers are responsible for clarifying the standards of acceptable
55
+ behavior and are expected to take appropriate and fair corrective action in
56
+ response to any instances of unacceptable behavior.
57
+
58
+ Project maintainers have the right and responsibility to remove, edit, or
59
+ reject comments, commits, code, wiki edits, issues, and other contributions
60
+ that are not aligned to this Code of Conduct, or to ban temporarily or
61
+ permanently any contributor for other behaviors that they deem inappropriate,
62
+ threatening, offensive, or harmful.
63
+
64
+ ### Scope
65
+
66
+ This Code of Conduct applies both within project spaces and in public spaces
67
+ when an individual is representing the project or its community. Examples of
68
+ representing a project or community include using an official project e-mail
69
+ address, posting via an official social media account, or acting as an appointed
70
+ representative at an online or offline event. Representation of a project may be
71
+ further defined and clarified by project maintainers.
72
+
73
+ ### Enforcement
74
+
75
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
76
+ reported by contacting me at [nareshnavinash@gmail.com]. All
77
+ complaints will be reviewed and investigated and will result in a response that
78
+ is deemed necessary and appropriate to the circumstances. The project member has
79
+ obligated to maintain confidentiality with regard to the reporter of an incident.
80
+ Further details of specific enforcement policies may be posted separately.
81
+
82
+ Project maintainers who do not follow or enforce the Code of Conduct in good
83
+ faith may face temporary or permanent repercussions as determined by other
84
+ members of the project's leadership.
85
+
86
+ ### Attribution
87
+
88
+
89
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
90
+ available at [http://contributor-covenant.org/version/1/4][version]
91
+
92
+ [homepage]: http://contributor-covenant.org
93
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,16 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'robotest'
4
+ gem 'selenium-webdriver'
5
+ gem 'rspec'
6
+ gem 'rspec-expectations'
7
+ gem 'rake'
8
+ gem 'headless'
9
+ gem 'pry'
10
+ gem 'require_all'
11
+ gem 'allure-rspec'
12
+ gem 'yaml_extend'
13
+ gem 'parallel_tests'
14
+ gem 'progress_bar'
15
+ gem 'coderay'
16
+ gem 'activesupport'
@@ -0,0 +1,12 @@
1
+ RoboTest is built over rspec, parallel_tests and allure.
2
+ 1. Install Sublime, Atom, Code or Xcode based on your preference
3
+ 2. Install homebrew from http://brew.sh/
4
+ 3. Install ruby and rvm with `brew install ruby` and `curl -sSL https://get.rvm.io | bash -s stable --ruby`
5
+ 4. Install chrome driver using `brew cask install chromedriver`
6
+ 5. For sample project run `robotest example` and move to that directory in the command prompt
7
+ 6. Now Make sure to rename the project name from `Full_Suite` to your `Custom Name`
8
+ 7. Rename the file `rspec_parallel` in Full_Suite/ folder to `.rspec_parallel` to get the console logs while running the scripts !!!
9
+ 8. To test a sample run with single process try running `robotest yaml/test.yml`
10
+ 9. To test a sample run with multiple process try running `robotest yaml/test_parallel.yml`
11
+ 10. You can specify the additional parameters as follows,\n> robotest yaml/test.yml -t sanity||true
12
+ Here test cases with sanity tag alone will run
@@ -0,0 +1,9 @@
1
+ require_relative "spec/spec_helper.rb"
2
+ task :rake_job_test1, [] do |t, args|
3
+ begin
4
+ RakeJobs.new()
5
+ rescue Exception => e
6
+ puts e
7
+ end
8
+ end
9
+
@@ -0,0 +1,2 @@
1
+ admin_email: freshdesk.1@gmail.com
2
+ common_password: Freshdesk@123
@@ -0,0 +1,25 @@
1
+ class Constants
2
+
3
+ attr_accessor :BASE_URL
4
+ attr_accessor :BASE_URL_FOR_ACCOUNTS
5
+ attr_accessor :COMMON_EMAIL
6
+ attr_accessor :COMMON_PASSWORD
7
+
8
+ def initialize
9
+ account_conf = ParseConfig.new("#{__dir__}/../test-data/credentials/test_credentials.conf")
10
+ conf_data = account_conf.params
11
+
12
+ @BASE_URL_FOR_ACCOUNTS = $conf["base_urls"]
13
+ @PARALLEL_TESTS = $conf["parallel_process"]
14
+ if $conf["base_urls"] != nil
15
+ if @PARALLEL_TESTS != nil
16
+ @BASE_URL = @BASE_URL_FOR_ACCOUNTS[0]
17
+ else
18
+ @BASE_URL = $conf["mode"] == 'parallel' ? @BASE_URL_FOR_ACCOUNTS[ENV[:TEST_ENV_NUMBER.to_s].to_i - 1] : @BASE_URL_FOR_ACCOUNTS[0]
19
+ end
20
+ end
21
+
22
+ @COMMON_EMAIL = conf_data["common_email"]
23
+ @COMMON_PASSWORD = conf_data["common_password"]
24
+ end
25
+ end
@@ -0,0 +1,52 @@
1
+ module AllureRSpec
2
+ module DSL
3
+ module Example
4
+
5
+ @@step_count = 0
6
+ @@current_example_location = nil
7
+
8
+ def step(step, *tags, &block)
9
+ __increment_step_count
10
+ metadata[:step_group] ||= {}
11
+ tags = tags[0].nil? ? {} : tags[0]
12
+ metadata[:step_group][@@step_count] = tags
13
+ metadata[:step_name] = step
14
+ test_case_name = metadata[:description]
15
+
16
+ suite = __description(metadata[:example_group])
17
+ test = __description(metadata)
18
+ begin
19
+ AllureRubyAdaptorApi::Builder.start_step(suite, test, step)
20
+ __with_step step, &block
21
+ puts "#{suite} - #{test_case_name} - #{step} - Passed"
22
+ __set_step_status('passed')
23
+ AllureRubyAdaptorApi::Builder.stop_step(suite, test, step)
24
+ rescue Exception => e
25
+ __set_step_status('failed')
26
+ puts "#{suite} - #{test_case_name} - #{step} - Failed"
27
+ AllureRubyAdaptorApi::Builder.stop_step(suite, test, step, :failed)
28
+ raise e
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def __increment_step_count
35
+ if @@current_example_location != metadata[:location]
36
+ __reset_step_count
37
+ @@current_example_location = metadata[:location]
38
+ else
39
+ @@step_count += 1
40
+ end
41
+ end
42
+
43
+ def __reset_step_count
44
+ @@step_count = 0
45
+ end
46
+
47
+ def __set_step_status(status)
48
+ metadata[:step_group][@@step_count][:status] = status
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,27 @@
1
+ module Locators
2
+ class TestPage
3
+
4
+ # All the Locators in the initialize block need to be declared here for read write permission.
5
+ attr_accessor :EMAIL_TEXTBOX
6
+ attr_accessor :PASSWORD_TEXTBOX
7
+ attr_accessor :LOGIN_LINK
8
+ attr_accessor :LOGIN_BUTTON
9
+ attr_accessor :SUBMIT_BUTTON
10
+
11
+ def initialize
12
+
13
+ # Locators can be declared here by mentioning {how?(xpath,css,id) and what?(identifier)}
14
+ @EMAIL_TEXTBOX = Locator.new(:id, "")
15
+ @PASSWORD_TEXTBOX = Locator.new(:xpath, "")
16
+ @LOGIN_LINK = Locator.new(:link, "Login")
17
+ @LOGIN_BUTTON = Locator.new(:css, "")
18
+ @SUBMIT_BUTTON = Locator.new(:css, "")
19
+ end
20
+
21
+ # Dynamic locators can be declared here as a seperate method (This method doesnot need to be declared with attr_accessor)
22
+ def LOGIN_DYNAMIC(variable)
23
+ @LOGIN_DYNAMIC = Locator.new(:xpath,"//*[text()=#{variable}]")
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ module Pages
2
+ class TestPage < Locators::TestPage
3
+
4
+ def initialize(driver)
5
+ super()
6
+ @driver = driver
7
+ end
8
+
9
+ def login(email, password, base_url = nil)
10
+ $focus_driver = @driver
11
+
12
+ #To navigate to the given url,
13
+ # @driver.get(base_url)
14
+
15
+ # Normal locators has to be used with the @
16
+ @LOGIN_LINK.is_present?
17
+
18
+ #Dynamic locators has to be declared without @
19
+ LOGIN_DYNAMIC("Login").is_present?
20
+
21
+ # Conditions can be used for a locator
22
+ if @EMAIL_TEXTBOX.is_present?
23
+ @EMAIL_TEXTBOX.clear_and_send_keys(email)
24
+ @PASSWORD_TEXTBOX.clear_and_send_keys(password)
25
+ @LOGIN_BUTTON.click
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ class RakeJobs
2
+ def initialize()
3
+
4
+ end
5
+
6
+ def setup
7
+ # to initialize via rake
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ --color
2
+ --format RspecJunitFormatter --out reports/junit/report_<%= ENV['TEST_ENV_NUMBER'] %>.xml
3
+ --format html --out reports/html/report_<%= ENV['TEST_ENV_NUMBER'] %>.html
4
+ --format json --out reports/json/report_<%= ENV['TEST_ENV_NUMBER'] %>.json
5
+ --format Fuubar --out reports/fuubar/report_<%= ENV['TEST_ENV_NUMBER'] %>.txt
6
+ --format progress
@@ -0,0 +1,84 @@
1
+ require 'robotest'
2
+ require 'require_all'
3
+ require 'allure-rspec'
4
+ require 'pathname'
5
+ require 'fileutils'
6
+ require 'headless'
7
+ require 'os'
8
+ require "pry"
9
+ require_rel "../locators/"
10
+ require_rel "../libraries/"
11
+ require_rel "../pages/"
12
+ require "time"
13
+ require "fileutils"
14
+ require 'uri'
15
+ require 'active_support/time'
16
+ require 'parseconfig'
17
+ include RoboTest
18
+
19
+ $conf = File.exist?('_robotest.yml') ? YAML.load_file('_robotest.yml') : raise "yaml file needs to be given as a input parameter"
20
+ FileUtils.mkdir_p("#{Pathname.pwd}/#{$conf['screenshot_location']}")
21
+ $browser = $conf['browser']
22
+
23
+ if OS.mac?
24
+ $conf["switches"].delete("headless") if $conf["switches"]
25
+ end
26
+
27
+ RSpec.configure do |config|
28
+ config.filter_run_when_matching :focus
29
+ config.example_status_persistence_file_path = "reports/examples.txt"
30
+ config.include AllureRSpec::Adaptor
31
+ end
32
+
33
+ AllureRSpec.configure do |config|
34
+ config.output_dir = "reports/allure"
35
+ config.clean_dir = true
36
+ config.logging_level = Logger::WARN
37
+ end
38
+
39
+ RSpec.configure do |c|
40
+
41
+ # To take screen shots of all the drivers when there is a failure
42
+ c.after(:each) do |example|
43
+ unless example.exception.nil?
44
+ begin
45
+ drivers = Driver.get_all_drivers
46
+ drivers.each do |l,m|
47
+ example.attach_file(m,l.save_screenshot)
48
+ end
49
+ rescue Exception => e
50
+ puts example.message
51
+ puts example.backtrace
52
+ end
53
+ end
54
+ puts "Runs after each in spec helper"
55
+ end
56
+
57
+ # To quit all the drivers after all the test cases are run.
58
+ c.after(:all) do |example|
59
+ Driver.quit_all_drivers
60
+ puts "Runs after all in spec helper"
61
+ end
62
+
63
+ # steps to be added which has to be run before all block (Common throughout the project)
64
+ c.before(:all) do |example|
65
+ puts "Runs before all in spec helper"
66
+ end
67
+
68
+ # steps to be added which has to be run before each block (Common throughout the project)
69
+ c.before(:each) do |example|
70
+ puts "#{example.metadata[:example_group][:description]} - #{example.metadata[:description]} - Started"
71
+ puts "Runs before each in spec helper"
72
+ end
73
+
74
+ # Following is the order in which the before and after blocks are run
75
+ # Runs before all in spec helper
76
+ # Runs before all in spec
77
+ # Runs before each in spec helper
78
+ # Runs before each in spec
79
+ # Runs after each in spec
80
+ # Runs after each in spec helper
81
+ # Runs after all in spec
82
+ # Runs after all in spec helper
83
+ end
84
+
@@ -0,0 +1,130 @@
1
+ # to require all the related gems and functionalities to this spec we need to give this in every spec file.
2
+ require 'spec_helper'
3
+
4
+ # Give a unique name in describe so that allure report will be created seperately.
5
+ # Note: If two spec has same name, allure will override the results of first spec with the second spec which has same name.
6
+ describe "Test Spec" do
7
+
8
+ before(:all) do
9
+ # Initialize all the constants here.
10
+
11
+ # Initialize a driver with a name, so that when there is a bug screen shots will be saved with the name.
12
+ # Multiple drivers can be initialized (with different properties, check driver.rb file in the gem for details)
13
+ # We can initialize one chrome, one firefox, one explorer, one safari browser at a time.
14
+ @driver1 = Driver.new("Test_Driver_1")
15
+ @driver2 = Driver.new("Test_Driver_2")
16
+ @driver3 = Driver.new("Test_Driver_3")
17
+ @driver4 = Driver.new("Test_Driver_4")
18
+
19
+ # To load the constants file from Constants class.
20
+ @constants = Constants.new
21
+
22
+ # Initialize the page class with the driver.
23
+ # Each instance method will be corresponding to the driver with which it is declared.
24
+ # New pages can be added and used in the same way
25
+ @driver1_login_page = Pages::TestPage.new(@driver1)
26
+ @driver2_login_page = Pages::TestPage.new(@driver2)
27
+ @driver3_login_page = Pages::TestPage.new(@driver3)
28
+ @driver4_login_page = Pages::TestPage.new(@driver4)
29
+
30
+ end
31
+
32
+ before(:each) do
33
+ # any specfic steps that needs to be done before each testcase can be done here
34
+ # Example : Moving to the home page after all the test case will be an idle one.
35
+ end
36
+
37
+ after(:all) do
38
+ # Steps that is to be run after all the test cases are done can be given here.
39
+ # Usual steps will be quiting all the drivers, but that is handled in the spec_helper.rb so any other specific steps other than quit can be given here.
40
+ end
41
+
42
+ after(:each) do |e|
43
+ # any specfic steps that needs to be done after each testcase can be done here
44
+ # Usually taking screen shots after each test case when there is a failure is done here, but that is covered in spec_helper.rb
45
+ # Any other steps than taking screenshot can be given here.
46
+ end
47
+
48
+
49
+ # Each test case can be declared with `it`
50
+ # after the test case name is defined we can define the tags for that test case
51
+ # These tags can be used to run only critical test cases, only sanity test cases or we can use the testId for any custom reporting.
52
+ it 'this test will pass',:severity => "critical", :sanity => true, :testId => '001' do |e|
53
+ # for more help on rspec expect statements you can visit the following website
54
+ # https://relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
55
+
56
+ # e.step is used by allure for reporting purpose. It is best to have all the lines inside any one of the e.step so that we can have a detailed reporting
57
+ e.step "true eql true" do
58
+ expect(true).to eq true
59
+ end
60
+ e.step "false eql false" do
61
+ expect(false).to eq false
62
+ end
63
+ e.step "string eql string" do
64
+ expect("test").to eq "test"
65
+ end
66
+ e.step "number eql number" do
67
+ expect(1).to eq 1
68
+ end
69
+ end
70
+
71
+ it "this test will fail", :severity => "critical", :testId => '002' do |e|
72
+ e.step "true eql true" do
73
+ expect(true).to eq true
74
+ end
75
+ e.step "false eql false" do
76
+ expect(false).to eq false
77
+ end
78
+ # Test case will fail in the below step
79
+ e.step "true eql false" do
80
+ expect(true).to eq false
81
+ end
82
+ # Since the above step is failed, following steps will not be executed.
83
+ e.step "true eql true" do
84
+ expect(true).to eq true
85
+ end
86
+ e.step "false eql false" do
87
+ expect(false).to eq false
88
+ end
89
+ end
90
+
91
+ it "this test will fail", :severity => "critical", :testId => '003' do |e|
92
+ e.step "true eql true" do
93
+ expect(true).to eq true
94
+ end
95
+ e.step "false eql false" do
96
+ expect(false).to eq false
97
+ end
98
+ # Test case will fail in the below step
99
+ # cstep is the custom method in which if a step fails it wont stop the test case
100
+ # this cstep can be used to validate data in a page, if we need to test and report 10 variables in a page, then we can use this so that all the validation point steps even if one step is failed
101
+ e.cstep "1 equal 2" do
102
+ expect(1).to eq 2
103
+ end
104
+ # even if the the above step is failed, following steps will be executed.
105
+ e.step "true eql true" do
106
+ expect(true).to eq true
107
+ end
108
+ e.step "false eql false" do
109
+ expect(false).to eq false
110
+ end
111
+ end
112
+
113
+ it 'Calling a function in a `Page` and `Object` from the spec file',:severity => "critical", :testId => '004' do |e|
114
+ # we can call a funtion in the pages in the following ways
115
+ e.step "Login to the application" do
116
+ @driver1_login_page.login(@constants.COMMON_EMAIL, @constants.COMMON_PASSWORD, @constants.BASE_URL)
117
+ Pages::TestPage.new(@driver2).login(@constants.COMMON_EMAIL, @constants.COMMON_PASSWORD, @constants.BASE_URL)
118
+ end
119
+
120
+ # we can call a locator with the page instance itself as follows,
121
+ e.step "Is login link is present" do
122
+ expect(@driver1_login_page.LOGIN_LINK.is_present?).to eql false
123
+ expect(@driver1_login_page.LOGIN_DYNAMIC("Login").is_present?).to eql false
124
+ end
125
+
126
+ end
127
+
128
+
129
+
130
+ end