applenium 0.0.3 → 0.0.4
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/.gitignore +6 -0
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +31 -0
- data/applenium.gemspec +25 -0
- data/bin/applenium +6 -26
- data/features/cucumber_template.feature +7 -0
- data/features/step_definitions/all_steps.rb +11 -0
- data/features/support/env.rb +6 -0
- data/features/support/support_code.rb +0 -0
- data/lib/applenium/mobile/mobile_methods.rb +2 -0
- data/lib/applenium/{methods → mobile}/required_files.rb +3 -3
- data/lib/applenium/mobile_steps.rb +13 -0
- data/lib/applenium/version.rb +1 -1
- data/lib/applenium/web/required_files.rb +8 -0
- data/lib/applenium/web/web_methods.rb +2 -0
- data/lib/applenium/web_steps.rb +13 -0
- data/lib/applenium.rb +5 -1
- data/scaffold/.relish +2 -0
- data/scaffold/.rubocop.yml +43 -0
- data/scaffold/.ruby-version +1 -0
- data/scaffold/.travis.yml +16 -0
- data/scaffold/.yard.yml +10 -0
- data/scaffold/Gemfile +16 -0
- data/scaffold/README.md +27 -0
- data/scaffold/browser.json +14 -0
- data/scaffold/ci_script +15 -0
- data/scaffold/cucumber.yml +10 -0
- data/scaffold/features/google.feature +7 -0
- data/scaffold/features/pages/Abstract.rb +14 -0
- data/scaffold/features/pages/HomePage.rb +22 -0
- data/scaffold/features/step_definitions/google_steps.rb +3 -0
- data/scaffold/features/support/env.rb +107 -0
- data/scaffold/features/support/helpers.erb +6 -0
- data/scaffold/features/support/hooks.rb +18 -0
- data/scaffold/features/support/responsive.rb +19 -0
- data/scaffold/lib/project/version.erb +3 -0
- data/scaffold/lib/project.erb +2 -0
- data/scaffold/package.json +11 -0
- data/scaffold/rake_tasks/cucumber.rb +8 -0
- data/scaffold/rake_tasks/cuke_sniffer.rb +4 -0
- data/scaffold/rake_tasks/rspec.rb +12 -0
- data/scaffold/rake_tasks/rubocop.rb +12 -0
- data/scaffold/rake_tasks/yard.rb +11 -0
- data/scaffold/spec/spec_helper.rb +8 -0
- metadata +76 -23
- data/bin/generate.rb +0 -20
- data/bin/helper.rb +0 -51
- data/lib/applenium/applenium_steps.rb +0 -14
- data/lib/applenium/methods/error_handling_methods.rb +0 -87
- data/lib/applenium/methods/misc_methods.rb +0 -33
- data/lib/applenium/methods/web_methods.rb +0 -35
- data/template/my_first.feature +0 -7
- data/template/step_definitions/custom_steps.rb +0 -1
- data/template/support/env.rb +0 -48
- data/template/support/hooks.rb +0 -38
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8fa9d6f48690aea8ce8b2b867394ab2330623c48
|
|
4
|
+
data.tar.gz: 2cdd9dde248b008604c5ecb0442367172a0c6652
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42269de300920615a809787b5016f3a4a1b31280450f6c21852e9ec06aee8fafd152e361889b2f94517c42521a4a9427090097455c164317044193a60baf802b
|
|
7
|
+
data.tar.gz: 79a676dc53197fe2ca176b4227168a1f2bd34904786fb27627b63821888d33f109f4af1704315a00e6bdf72e14e081c1d9dbca2e3dc7b8b84503f5ec502e2e7d
|
data/.gitignore
ADDED
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
We would love to get any pull requests. Here's a quick guide.
|
|
4
|
+
|
|
5
|
+
Fork, then clone the repo:
|
|
6
|
+
|
|
7
|
+
git clone git@github.com:your-username/selenium-cucumber.git
|
|
8
|
+
|
|
9
|
+
Run `/example` tests through your local repo:
|
|
10
|
+
|
|
11
|
+
1. cd your_repo
|
|
12
|
+
2. cd example
|
|
13
|
+
3. Open Gemfile
|
|
14
|
+
4. Uncomment `gem 'selenium-cucumber', path: 'your local repo path'` and
|
|
15
|
+
replace 'your local repo path' with your local repo path
|
|
16
|
+
5. Comment out `gem 'selenium-cucumber'`
|
|
17
|
+
6. bundle install
|
|
18
|
+
7. Run tests as:
|
|
19
|
+
`cucumber` (or `cucumber features/any_feature_name.feature`)
|
|
20
|
+
|
|
21
|
+
Make your change. Add tests for your change in `/example`.
|
|
22
|
+
Make sure to run all the test(or features) successfully.
|
|
23
|
+
Commit your changes but don't forget to revert the changes of comment/uncomment
|
|
24
|
+
in Gemfile(done to run tests through local repo).
|
|
25
|
+
|
|
26
|
+
Push to your fork and [submit a pull request][pr].
|
|
27
|
+
|
|
28
|
+
[pr]: https://github.com/sameer49/selenium-cucumber-ruby/compare
|
|
29
|
+
|
|
30
|
+
At this point you're waiting on us. We like to at least comment on pull requests
|
|
31
|
+
or may suggest some changes or discuss improvements or alternatives.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015 Shashikant86
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Applenium
|
|
2
|
+
|
|
3
|
+
TODO: Write a gem description
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'applenium'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install applenium
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
TODO: Write usage instructions here
|
|
24
|
+
|
|
25
|
+
## Contributing
|
|
26
|
+
|
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/appplenium/fork )
|
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
31
|
+
5. Create a new Pull Request
|
data/applenium.gemspec
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
2
|
+
require 'applenium/version'
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = 'applenium'
|
|
6
|
+
s.version = Applenium::VERSION
|
|
7
|
+
s.date = Time.now
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.licenses = ['MIT']
|
|
10
|
+
s.summary = 'Appium and Selenium used with Ruby Cucumber'
|
|
11
|
+
s.description = 'Mobile and Web apps automation framework using Appium, Selenium and Cucumber'
|
|
12
|
+
s.authors = 'Shashikant86'
|
|
13
|
+
s.homepage = ''
|
|
14
|
+
s.email = 'shashikant.jagtap@aol.co.uk'
|
|
15
|
+
s.require_paths = ['lib']
|
|
16
|
+
s.post_install_message = 'Thank you for installing applenium gem.'
|
|
17
|
+
s.add_runtime_dependency "cucumber", '~> 1.3', '>= 1.3.18'
|
|
18
|
+
s.add_runtime_dependency "capybara", '~> 2.4.4', '>= 2.4.1'
|
|
19
|
+
s.add_runtime_dependency "rspec", '~> 3.2.0', '>= 3.0.0'
|
|
20
|
+
s.add_runtime_dependency "selenium-webdriver", '~> 2.44.0', '>= 2.41.0'
|
|
21
|
+
s.files = `git ls-files`.split("\n")
|
|
22
|
+
s.test_files = `git ls-files -- {features}/*`.split("\n")
|
|
23
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
24
|
+
s.require_paths = ["lib"]
|
|
25
|
+
end
|
data/bin/applenium
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
require '
|
|
3
|
+
lib_dir = File.expand_path("../lib", File.dirname(__FILE__))
|
|
4
|
+
$:.unshift lib_dir unless $:.include?(lib_dir)
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
@root_dir =File.join(FileUtils.pwd, "framework")
|
|
7
|
+
@source_dir = File.join(File.dirname(__FILE__), '..', 'scaffold')
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
@support_dir = File.join(@features_dir, "support")
|
|
9
|
-
@support_dir = File.join(@features_dir, "expected_images")
|
|
10
|
-
@support_dir = File.join(@features_dir, "actual_images")
|
|
11
|
-
@support_dir = File.join(@features_dir, "image_difference")
|
|
12
|
-
@support_dir = File.join(@features_dir, "screenshots")
|
|
13
|
-
@source_dir = File.join(File.dirname(__FILE__), '..', 'template')
|
|
14
|
-
|
|
15
|
-
if (ARGV.length == 0)
|
|
16
|
-
print_usage
|
|
17
|
-
else
|
|
18
|
-
cmd = ARGV.shift
|
|
19
|
-
|
|
20
|
-
if cmd == "help"
|
|
21
|
-
print_help
|
|
22
|
-
elsif cmd == "gen"
|
|
23
|
-
applenium_template
|
|
24
|
-
elsif cmd == "version"
|
|
25
|
-
puts Applenium::VERSION
|
|
26
|
-
else
|
|
27
|
-
print_usage
|
|
28
|
-
end
|
|
29
|
-
end
|
|
9
|
+
FileUtils.cp_r(@source_dir, @root_dir)
|
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
|
+
require 'cucumber'
|
|
3
|
+
require 'capybara'
|
|
4
|
+
require 'rspec'
|
|
2
5
|
require 'selenium-webdriver'
|
|
3
6
|
require 'open-uri'
|
|
4
7
|
require 'rbconfig'
|
|
5
|
-
require 'appium_lib'
|
|
6
8
|
include RbConfig
|
|
7
|
-
require_relative 'misc_methods'
|
|
8
|
-
require_relative 'error_handling_methods'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# require_relative 'mobile/mobile_methods'
|
|
2
|
+
#
|
|
3
|
+
# Given(/^I am on "(.*?)"$/) do |url|
|
|
4
|
+
# visit(url)
|
|
5
|
+
# end
|
|
6
|
+
#
|
|
7
|
+
# When(/^I fill in "(.*?)" with "(.*?)"$/) do |element, text|
|
|
8
|
+
# fill_in element, with: text
|
|
9
|
+
# end
|
|
10
|
+
#
|
|
11
|
+
# Then(/^I should see "(.*?)"$/) do |text|
|
|
12
|
+
# page.should have_content text
|
|
13
|
+
# end
|
data/lib/applenium/version.rb
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative 'web/web_methods'
|
|
2
|
+
|
|
3
|
+
Given(/^I am on "(.*?)"$/) do |url|
|
|
4
|
+
visit(url)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
When(/^I fill in "(.*?)" with "(.*?)"$/) do |element, text|
|
|
8
|
+
fill_in element, with: text
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
Then(/^I should see "(.*?)"$/) do |text|
|
|
12
|
+
page.should have_content text
|
|
13
|
+
end
|
data/lib/applenium.rb
CHANGED
data/scaffold/.relish
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Include:
|
|
3
|
+
- Gemfile
|
|
4
|
+
- Rakefile
|
|
5
|
+
Exclude:
|
|
6
|
+
- bin/**/*
|
|
7
|
+
- vendor/**/*
|
|
8
|
+
- tmp/**/*
|
|
9
|
+
|
|
10
|
+
CollectionMethods:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
13
|
+
Encoding:
|
|
14
|
+
Enabled: false
|
|
15
|
+
|
|
16
|
+
LineLength:
|
|
17
|
+
Max: 119
|
|
18
|
+
|
|
19
|
+
Documentation:
|
|
20
|
+
Enabled: false
|
|
21
|
+
|
|
22
|
+
CaseIndentation:
|
|
23
|
+
Enabled: false
|
|
24
|
+
|
|
25
|
+
DotPosition:
|
|
26
|
+
Enabled: false
|
|
27
|
+
|
|
28
|
+
MethodLength:
|
|
29
|
+
CountComments: false
|
|
30
|
+
Max: 20
|
|
31
|
+
|
|
32
|
+
Blocks:
|
|
33
|
+
Enabled: false
|
|
34
|
+
Enabled: false
|
|
35
|
+
|
|
36
|
+
AlignParameters:
|
|
37
|
+
Enabled: false
|
|
38
|
+
|
|
39
|
+
IfUnlessModifier:
|
|
40
|
+
Enabled: false
|
|
41
|
+
|
|
42
|
+
TrailingComma:
|
|
43
|
+
Enabled: false
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ruby-1.9.3-p194
|
data/scaffold/.yard.yml
ADDED
data/scaffold/Gemfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
gem 'nokogiri', '1.6.1'
|
|
3
|
+
gem 'cucumber'
|
|
4
|
+
gem 'capybara'
|
|
5
|
+
gem 'applenium'
|
|
6
|
+
gem 'selenium-webdriver'
|
|
7
|
+
gem 'poltergeist'
|
|
8
|
+
gem 'rake'
|
|
9
|
+
gem 'yard-cucumber'
|
|
10
|
+
gem 'redcarpet'
|
|
11
|
+
gem 'rubocop'
|
|
12
|
+
gem 'cuke_sniffer'
|
|
13
|
+
gem 'json'
|
|
14
|
+
gem 'rspec'
|
|
15
|
+
gem 'relish'
|
|
16
|
+
gem 'rubocop-checkstyle_formatter'
|
data/scaffold/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
BDD Scenarios
|
|
2
|
+
========================
|
|
3
|
+
|
|
4
|
+
## Install
|
|
5
|
+
|
|
6
|
+
Your description to install project
|
|
7
|
+
|
|
8
|
+
$ bundle install
|
|
9
|
+
Make sure you are using corect ruby version.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Run cucumber bundle tasks
|
|
14
|
+
|
|
15
|
+
$ bundle exec cucumber -p selenium
|
|
16
|
+
|
|
17
|
+
### Run Rake tasks
|
|
18
|
+
|
|
19
|
+
$ bundle exec rake [task name]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Running on CI
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Your steps to run the things on CI goes here
|
|
26
|
+
|
|
27
|
+
|
data/scaffold/ci_script
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
RAKETASK=$1
|
|
3
|
+
rm -rf ${WORKSPACE}/target/
|
|
4
|
+
rm -rf ${WORKSPACE}/.yarddoc/
|
|
5
|
+
rm -rf ${WORKSPACE}/doc/
|
|
6
|
+
mkdir -p ${WORKSPACE}/target/
|
|
7
|
+
bundle install --path vendor/bundle --binstubs
|
|
8
|
+
bundle exec yard config load_plugins true
|
|
9
|
+
bundle exec yardoc 'example/**/*.rb' 'example/**/*.feature'
|
|
10
|
+
bundle exec rake yard
|
|
11
|
+
cd ${WORKSPACE}/features
|
|
12
|
+
bundle exec cuke_sniffer --out html ${WORKSPACE}/target/cuke_sniffer.html
|
|
13
|
+
bundle exec rubocop ${WORKSPACE}/features/ --require rubocop/formatter/checkstyle_formatter --format Rubocop::Formatter::CheckstyleFormatter --no-color --silent --rails --out ${WORKSPACE}/target/checkstyle.xml
|
|
14
|
+
cd ${WORKSPACE}
|
|
15
|
+
bundle exec rake "${RAKETASK}"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
default: -p selenium
|
|
2
|
+
html_report: --format pretty --format html --out=features_report.html
|
|
3
|
+
bvt: --tags @test
|
|
4
|
+
browserstack : DRIVER=browserstack
|
|
5
|
+
testingbot: DRIVER=testingbot
|
|
6
|
+
poltergeist : DRIVER=poltergeist
|
|
7
|
+
selenium : DRIVER=selenium
|
|
8
|
+
appium_android : DRIVER=appium_android
|
|
9
|
+
appium_ios : DRIVER=appium_ios
|
|
10
|
+
sauce : DRIVER=sauce
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class HomePage
|
|
2
|
+
class << self
|
|
3
|
+
attr_accessor :title, :title_text
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
self.title_text = "Your Site "
|
|
7
|
+
self.title = "your_css_selector"
|
|
8
|
+
|
|
9
|
+
def initialize(session)
|
|
10
|
+
@session = Capybara.current_session
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def visit_home_page
|
|
14
|
+
@session.visit("your_url")
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
=begin
|
|
19
|
+
You can the use these methods in the step_definitions as
|
|
20
|
+
@home_page = HomePage.new(Capybara.current_session)
|
|
21
|
+
@home_page.visit_home_page
|
|
22
|
+
=end
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
require "Capybara/cucumber"
|
|
4
|
+
require "rspec"
|
|
5
|
+
require 'capybara/poltergeist'
|
|
6
|
+
require 'selenium-webdriver'
|
|
7
|
+
require 'rubocop'
|
|
8
|
+
require 'applenium'
|
|
9
|
+
|
|
10
|
+
Capybara.configure do |config|
|
|
11
|
+
|
|
12
|
+
config.run_server = false
|
|
13
|
+
config.default_driver = (ENV['DRIVER'] || 'selenium').to_sym
|
|
14
|
+
config.javascript_driver = config.default_driver
|
|
15
|
+
config.default_selector = :xpath
|
|
16
|
+
config.default_wait_time = 60
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Capybara.register_driver :selenium do |app|
|
|
20
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
21
|
+
Capybara::Selenium::Driver.new(app, :profile => profile)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Capybara.register_driver :poltergeist do |app|
|
|
25
|
+
|
|
26
|
+
options = {
|
|
27
|
+
:js_errors => true,
|
|
28
|
+
:timeout => 120,
|
|
29
|
+
:debug => false,
|
|
30
|
+
:phantomjs_options => ['--load-images=no', '--disk-cache=false'],
|
|
31
|
+
:inspector => true,
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Capybara::Poltergeist::Driver.new(app, options)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
Capybara.register_driver :browserstack do |app|
|
|
39
|
+
stackToUse = ENV['BS_STACK'] || 'osx_firefox'
|
|
40
|
+
json = JSON.load(open(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'browsers.json'))))
|
|
41
|
+
config = json[stackToUse]
|
|
42
|
+
unless config
|
|
43
|
+
puts "invalid BS_STACK specified. Was '#{stackToUse}'"
|
|
44
|
+
return
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Add default config
|
|
48
|
+
config['name'] = "#{config['os']} #{config['os_version']} - #{Time.now.strftime '%Y-%m-%d %H:%M'}"
|
|
49
|
+
config['acceptSslCert'] = false
|
|
50
|
+
config['browserstack.debug'] = true
|
|
51
|
+
|
|
52
|
+
Capybara::Selenium::Driver.new(app,
|
|
53
|
+
:browser => :remote,
|
|
54
|
+
:desired_capabilities => config,
|
|
55
|
+
:url => "http://USERNAME:API_KEY@hub.browserstack.com/wd/hub"
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
Capybara.register_driver :testingbot do |app|
|
|
60
|
+
stackToUse = ENV['TB_STACK'] || 'osx_firefox'
|
|
61
|
+
json = JSON.load(open(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'browsers.json'))))
|
|
62
|
+
config = json[stackToUse]
|
|
63
|
+
unless config
|
|
64
|
+
puts "invalid TB_STACK specified. Was '#{stackToUse}'"
|
|
65
|
+
return
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Add default config
|
|
69
|
+
config['name'] = "#{config['os']} #{config['os_version']} - #{Time.now.strftime '%Y-%m-%d %H:%M'}"
|
|
70
|
+
config['acceptSslCert'] = false
|
|
71
|
+
|
|
72
|
+
Capybara::Selenium::Driver.new(app,
|
|
73
|
+
:browser => :remote,
|
|
74
|
+
:desired_capabilities => config,
|
|
75
|
+
:url => "http://KEY:SECRET@hub.testingbot.com/wd/hub"
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
Capybara.register_driver :sauce do |app|
|
|
80
|
+
job_name = "Cucumber-Tests - #{Time.now.strftime '%Y-%m-%d %H:%M'}"
|
|
81
|
+
browser = ENV['SAUCE_BROWSER'] || 'firefox'
|
|
82
|
+
version = ENV['SAUCE_VERSION'] || '3.6'
|
|
83
|
+
platform = ENV['SAUCE_PLATFORM'] || 'WINDOWS'
|
|
84
|
+
duration = 7200
|
|
85
|
+
capabilities = {:browserName => browser, :version => version, :platform => platform, :name => job_name, "max-duration" => duration}
|
|
86
|
+
puts "Running #{job_name} on SauceLabs with #{browser} #{version} on #{platform}"
|
|
87
|
+
Capybara::Selenium::Driver.new(app,
|
|
88
|
+
:browser => :remote,
|
|
89
|
+
:desired_capabilities => capabilities,
|
|
90
|
+
:url => "http://SAUCE_USERNAME:SAUCE_API_KEY@ondemand.saucelabs.com:80/wd/hub")
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Capybara.register_driver :appium_android do |app|
|
|
94
|
+
capabilities = {:platformName => 'Android', :deviceName => 'android', :browserName => 'Chrome', :uuid => ENV['ADB_SERIAL']}
|
|
95
|
+
Capybara::Selenium::Driver.new(app,
|
|
96
|
+
:browser => :remote,
|
|
97
|
+
:desired_capabilities => capabilities,
|
|
98
|
+
:url => "http://0.0.0.0:4723/wd/hub")
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
Capybara.register_driver :appium_ios do |app|
|
|
102
|
+
capabilities = {:platformName => 'iOS', :platformVersion => '8.0', :deviceName=> 'iPhone 6', :browserName => 'Safari', :version => '6.0'}
|
|
103
|
+
Capybara::Selenium::Driver.new(app,
|
|
104
|
+
:browser => :remote,
|
|
105
|
+
:desired_capabilities => capabilities,
|
|
106
|
+
:url => "http://0.0.0.0:4723/wd/hub")
|
|
107
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Before do
|
|
2
|
+
## setup code
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
After do
|
|
6
|
+
## teardown code
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
Before('@wip, @ci') do
|
|
10
|
+
# This will only run before scenarios tagged
|
|
11
|
+
# with @wip OR @ci.
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
AfterStep('@wip', '@ci') do
|
|
16
|
+
# This will only run after steps within scenarios tagged
|
|
17
|
+
# with @wip AND @ci.
|
|
18
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
def set_window_size(width, height)
|
|
2
|
+
if Capybara.current_driver == :selenium
|
|
3
|
+
Capybara.current_session.driver.browser.manage.window.resize_to(width, height)
|
|
4
|
+
elsif Capybara.current_driver == :poltergeist
|
|
5
|
+
Capybara.current_session.driver.resize(width, height)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
begin
|
|
10
|
+
window_sizes = {
|
|
11
|
+
:'320' => { :width => 320, :height => 480 },
|
|
12
|
+
:'600' => { :width => 600, :height => 769 },
|
|
13
|
+
:'770' => { :width => 770, :height => 1025 },
|
|
14
|
+
:'1026' => { :width => 1026, :height => 1200 },
|
|
15
|
+
}
|
|
16
|
+
window_sizes.default = { :width => 994, :height=> 689 }
|
|
17
|
+
size = window_sizes[(ENV['DEVICE'] || 'default').to_sym]
|
|
18
|
+
set_window_size(size[:width], size[:height])
|
|
19
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require 'cucumber/rake/task'
|
|
2
|
+
Cucumber::Rake::Task.new(:features) do |features|
|
|
3
|
+
features.cucumber_opts = "features -p selenium --format progress"
|
|
4
|
+
end
|
|
5
|
+
Cucumber::Rake::Task.new(:features_ci) do |task|
|
|
6
|
+
task.cucumber_opts = ["-p poltergeist -f pretty -f junit --out target/ -f html --out target/report.html"]
|
|
7
|
+
end
|
|
8
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'rspec/core/rake_task'
|
|
2
|
+
desc "Run specs"
|
|
3
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
|
4
|
+
t.rspec_opts = %w(--color)
|
|
5
|
+
end
|
|
6
|
+
namespace :spec do
|
|
7
|
+
desc "Run specs with output in documentation format"
|
|
8
|
+
RSpec::Core::RakeTask.new(:doc) do |t|
|
|
9
|
+
t.rspec_opts = ["--color", "--format d"]
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'yard'
|
|
2
|
+
|
|
3
|
+
YARD::Rake::YardocTask.new do |t|
|
|
4
|
+
t.files = ['features/**/*.feature', 'features/**/*.rb']
|
|
5
|
+
t.options = ['--any', '--extra', '--opts'] # optional
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
task :yard_bundle do
|
|
9
|
+
sh "bundle exec yardoc 'example/**/*.rb' 'example/**/*.feature'"
|
|
10
|
+
end
|
|
11
|
+
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: applenium
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shashikant86
|
|
@@ -31,45 +31,65 @@ dependencies:
|
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: 1.3.18
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
|
-
name:
|
|
34
|
+
name: capybara
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ~>
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 2.
|
|
39
|
+
version: 2.4.4
|
|
40
40
|
- - '>='
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: 2.
|
|
42
|
+
version: 2.4.1
|
|
43
43
|
type: :runtime
|
|
44
44
|
prerelease: false
|
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
46
|
requirements:
|
|
47
47
|
- - ~>
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: 2.
|
|
49
|
+
version: 2.4.4
|
|
50
50
|
- - '>='
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: 2.
|
|
52
|
+
version: 2.4.1
|
|
53
|
+
- !ruby/object:Gem::Dependency
|
|
54
|
+
name: rspec
|
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ~>
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: 3.2.0
|
|
60
|
+
- - '>='
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: 3.0.0
|
|
63
|
+
type: :runtime
|
|
64
|
+
prerelease: false
|
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ~>
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: 3.2.0
|
|
70
|
+
- - '>='
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: 3.0.0
|
|
53
73
|
- !ruby/object:Gem::Dependency
|
|
54
|
-
name:
|
|
74
|
+
name: selenium-webdriver
|
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|
|
56
76
|
requirements:
|
|
57
77
|
- - ~>
|
|
58
78
|
- !ruby/object:Gem::Version
|
|
59
|
-
version:
|
|
79
|
+
version: 2.44.0
|
|
60
80
|
- - '>='
|
|
61
81
|
- !ruby/object:Gem::Version
|
|
62
|
-
version:
|
|
82
|
+
version: 2.41.0
|
|
63
83
|
type: :runtime
|
|
64
84
|
prerelease: false
|
|
65
85
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
86
|
requirements:
|
|
67
87
|
- - ~>
|
|
68
88
|
- !ruby/object:Gem::Version
|
|
69
|
-
version:
|
|
89
|
+
version: 2.44.0
|
|
70
90
|
- - '>='
|
|
71
91
|
- !ruby/object:Gem::Version
|
|
72
|
-
version:
|
|
92
|
+
version: 2.41.0
|
|
73
93
|
description: Mobile and Web apps automation framework using Appium, Selenium and Cucumber
|
|
74
94
|
email: shashikant.jagtap@aol.co.uk
|
|
75
95
|
executables:
|
|
@@ -77,20 +97,52 @@ executables:
|
|
|
77
97
|
extensions: []
|
|
78
98
|
extra_rdoc_files: []
|
|
79
99
|
files:
|
|
100
|
+
- .gitignore
|
|
101
|
+
- CONTRIBUTING.md
|
|
102
|
+
- Gemfile
|
|
103
|
+
- LICENSE
|
|
104
|
+
- README.md
|
|
105
|
+
- applenium.gemspec
|
|
80
106
|
- bin/applenium
|
|
81
|
-
-
|
|
82
|
-
-
|
|
107
|
+
- features/cucumber_template.feature
|
|
108
|
+
- features/step_definitions/all_steps.rb
|
|
109
|
+
- features/support/env.rb
|
|
110
|
+
- features/support/support_code.rb
|
|
83
111
|
- lib/applenium.rb
|
|
84
|
-
- lib/applenium/
|
|
85
|
-
- lib/applenium/
|
|
86
|
-
- lib/applenium/
|
|
87
|
-
- lib/applenium/methods/required_files.rb
|
|
88
|
-
- lib/applenium/methods/web_methods.rb
|
|
112
|
+
- lib/applenium/mobile/mobile_methods.rb
|
|
113
|
+
- lib/applenium/mobile/required_files.rb
|
|
114
|
+
- lib/applenium/mobile_steps.rb
|
|
89
115
|
- lib/applenium/version.rb
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
116
|
+
- lib/applenium/web/required_files.rb
|
|
117
|
+
- lib/applenium/web/web_methods.rb
|
|
118
|
+
- lib/applenium/web_steps.rb
|
|
119
|
+
- scaffold/.relish
|
|
120
|
+
- scaffold/.rubocop.yml
|
|
121
|
+
- scaffold/.ruby-version
|
|
122
|
+
- scaffold/.travis.yml
|
|
123
|
+
- scaffold/.yard.yml
|
|
124
|
+
- scaffold/Gemfile
|
|
125
|
+
- scaffold/README.md
|
|
126
|
+
- scaffold/browser.json
|
|
127
|
+
- scaffold/ci_script
|
|
128
|
+
- scaffold/cucumber.yml
|
|
129
|
+
- scaffold/features/google.feature
|
|
130
|
+
- scaffold/features/pages/Abstract.rb
|
|
131
|
+
- scaffold/features/pages/HomePage.rb
|
|
132
|
+
- scaffold/features/step_definitions/google_steps.rb
|
|
133
|
+
- scaffold/features/support/env.rb
|
|
134
|
+
- scaffold/features/support/helpers.erb
|
|
135
|
+
- scaffold/features/support/hooks.rb
|
|
136
|
+
- scaffold/features/support/responsive.rb
|
|
137
|
+
- scaffold/lib/project.erb
|
|
138
|
+
- scaffold/lib/project/version.erb
|
|
139
|
+
- scaffold/package.json
|
|
140
|
+
- scaffold/rake_tasks/cucumber.rb
|
|
141
|
+
- scaffold/rake_tasks/cuke_sniffer.rb
|
|
142
|
+
- scaffold/rake_tasks/rspec.rb
|
|
143
|
+
- scaffold/rake_tasks/rubocop.rb
|
|
144
|
+
- scaffold/rake_tasks/yard.rb
|
|
145
|
+
- scaffold/spec/spec_helper.rb
|
|
94
146
|
homepage: ''
|
|
95
147
|
licenses:
|
|
96
148
|
- MIT
|
|
@@ -103,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
103
155
|
requirements:
|
|
104
156
|
- - '>='
|
|
105
157
|
- !ruby/object:Gem::Version
|
|
106
|
-
version:
|
|
158
|
+
version: '0'
|
|
107
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
160
|
requirements:
|
|
109
161
|
- - '>='
|
|
@@ -116,3 +168,4 @@ signing_key:
|
|
|
116
168
|
specification_version: 4
|
|
117
169
|
summary: Appium and Selenium used with Ruby Cucumber
|
|
118
170
|
test_files: []
|
|
171
|
+
has_rdoc:
|
data/bin/generate.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
def applenium_template
|
|
3
|
-
if File.exists?(@features_dir)
|
|
4
|
-
puts "A features directory already exists. Stopping..."
|
|
5
|
-
exit 1
|
|
6
|
-
end
|
|
7
|
-
msg("Question") do
|
|
8
|
-
puts "I'm about to create a subdirectory called features."
|
|
9
|
-
puts "features will contain all your project tests."
|
|
10
|
-
puts "Please hit return to confirm that's what you want."
|
|
11
|
-
end
|
|
12
|
-
exit 2 unless STDIN.gets.chomp == ''
|
|
13
|
-
|
|
14
|
-
FileUtils.cp_r(@source_dir, @features_dir)
|
|
15
|
-
|
|
16
|
-
msg("Info") do
|
|
17
|
-
puts "features subdirectory created. \n"
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
data/bin/helper.rb
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
require 'tempfile'
|
|
2
|
-
require 'json'
|
|
3
|
-
require "rubygems"
|
|
4
|
-
|
|
5
|
-
def msg(title, &block)
|
|
6
|
-
puts "\n" + "-"*10 + title + "-"*10
|
|
7
|
-
block.call
|
|
8
|
-
puts "-"*10 + "-------" + "-"*10 + "\n"
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def print_usage
|
|
12
|
-
puts <<EOF
|
|
13
|
-
|
|
14
|
-
Usage: applenium <command-name> [parameters] [options]
|
|
15
|
-
|
|
16
|
-
<command-name> can be one of
|
|
17
|
-
help
|
|
18
|
-
prints more detailed help information.
|
|
19
|
-
gen
|
|
20
|
-
generate a features folder structure.
|
|
21
|
-
version
|
|
22
|
-
prints the gem version
|
|
23
|
-
|
|
24
|
-
<options> can be
|
|
25
|
-
-v, --verbose Turns on verbose logging
|
|
26
|
-
EOF
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def print_help
|
|
30
|
-
puts <<EOF
|
|
31
|
-
|
|
32
|
-
Usage: applenium <command-name> [parameters] [options]
|
|
33
|
-
|
|
34
|
-
<command-name> can be one of
|
|
35
|
-
help
|
|
36
|
-
gen
|
|
37
|
-
version
|
|
38
|
-
|
|
39
|
-
Commands:
|
|
40
|
-
help : prints more detailed help information.
|
|
41
|
-
|
|
42
|
-
gen : creates a skeleton features dir. This is usually used once when
|
|
43
|
-
setting up selnium-cucumber to ensure that the features folder contains
|
|
44
|
-
the right step definitions and environment to run with cucumber.
|
|
45
|
-
|
|
46
|
-
version : prints the gem version
|
|
47
|
-
|
|
48
|
-
<Options>
|
|
49
|
-
-v, --verbose Turns on verbose logging
|
|
50
|
-
EOF
|
|
51
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require_relative 'methods/web_methods'
|
|
2
|
-
|
|
3
|
-
Given(/^I am on "([^\"]*)"$/)do |link|
|
|
4
|
-
visit(link)
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
When(/^I click on element having (.+) "(.*?)"$/) do |type, access_name|
|
|
8
|
-
validate_locator type
|
|
9
|
-
click(type, access_name)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
Then(/^link having text "(.*?)" should\s*((?:not)?)\s+be present$/) do |access_name, present|
|
|
13
|
-
check_element_on_page('link', access_name, present.empty?)
|
|
14
|
-
end
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# Error handling methods
|
|
2
|
-
|
|
3
|
-
# Method to check browser type
|
|
4
|
-
def validate_parameters(platform, browser_type, app_path)
|
|
5
|
-
if platform == 'desktop'
|
|
6
|
-
if !%w(ff ie chrome safari opera).include? browser_type
|
|
7
|
-
print_error_desktop
|
|
8
|
-
end
|
|
9
|
-
elsif platform == 'android'
|
|
10
|
-
print_error_android browser_type, app_path
|
|
11
|
-
elsif platform == 'iOS'
|
|
12
|
-
puts "Not Implemented..."
|
|
13
|
-
# print_error_ios browser_type, app_path
|
|
14
|
-
else
|
|
15
|
-
print_invalid_platform
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
# print error for desktop
|
|
20
|
-
def print_error_desktop
|
|
21
|
-
puts "\nInappropraite desktop browser : \"#{ENV['BROWSER']}\""
|
|
22
|
-
puts "\nUsage : cucumber BROWSER=browser_name"
|
|
23
|
-
puts "\nBrowser Supported :\n"
|
|
24
|
-
puts "\n1.ie\n2.chrome\n3.ff\n4.safari\n5.opera"
|
|
25
|
-
Process.exit(0)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# print error for android
|
|
29
|
-
def print_error_android(browser_type, app_path)
|
|
30
|
-
if browser_type=='ff' and app_path==nil
|
|
31
|
-
puts "\nOops... not mentioned \"Browser\" or \"App path\""
|
|
32
|
-
print_error_android_app
|
|
33
|
-
print_error_android_web
|
|
34
|
-
Process.exit(0)
|
|
35
|
-
elsif browser_type!='ff' and !%w(native chrome).include? browser_type
|
|
36
|
-
puts "\nOops... not supported browser"
|
|
37
|
-
print_error_android_web
|
|
38
|
-
Process.exit(0)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# print error for android app
|
|
43
|
-
def print_error_android_app
|
|
44
|
-
puts "\nTo run test on android app"
|
|
45
|
-
puts "\n Usage : cucumber PLATFORM=android APP_PATH=path/to/app"
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# print error for android web
|
|
49
|
-
def print_error_android_web
|
|
50
|
-
puts "\nTo run test on android mobile web"
|
|
51
|
-
puts "\n Usage : cucumber PLATFORM=android BROWSER=browser_name"
|
|
52
|
-
puts "\n Supported browsers are \"chrome\" and \"native\""
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# print error for ios
|
|
56
|
-
def print_error_ios
|
|
57
|
-
if browser_type=='ff' and app_path==nil
|
|
58
|
-
puts "\nOops... not mentioned \"Browser\" or \"App path\""
|
|
59
|
-
print_error_ios_app
|
|
60
|
-
print_error_ios_web
|
|
61
|
-
Process.exit(0)
|
|
62
|
-
elsif browser_type!='safari'
|
|
63
|
-
puts "\nOops... not supported browser"
|
|
64
|
-
print_error_ios_app_web
|
|
65
|
-
Process.exit(0)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# print error for ios app
|
|
70
|
-
def print_error_ios_app
|
|
71
|
-
puts "\nTo run test on iOS App"
|
|
72
|
-
puts "\n Usage : cucumber PLATFORM=iOS APP_PATH=path/to/app"
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# print error for ios web
|
|
76
|
-
def print_error_ios_web
|
|
77
|
-
puts "\nTo run test on iOS mobile web"
|
|
78
|
-
puts "\n Usage : cucumber PLATFORM=iOS BROWSER=safari"
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
# print error if invalid platform
|
|
82
|
-
def print_invalid_platform
|
|
83
|
-
puts "\nOops... Invalid Platform"
|
|
84
|
-
puts "\nSupported platform are \"android\" and \"iOS\"."
|
|
85
|
-
puts "\nTo run on Desktop no need to mention platform."
|
|
86
|
-
Process.exit(0)
|
|
87
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# custome exception class
|
|
2
|
-
class TestCaseFailed < Exception
|
|
3
|
-
end
|
|
4
|
-
|
|
5
|
-
# WAIT instance for explicit wait
|
|
6
|
-
WAIT = Selenium::WebDriver::Wait.new(:timeout => 30)
|
|
7
|
-
|
|
8
|
-
# method to validate locator
|
|
9
|
-
def valid_locator_type? type
|
|
10
|
-
%w(id class css name xpath).include? type
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def validate_locator type
|
|
14
|
-
raise "Invalid locator type - #{type}" unless valid_locator_type? type
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# method to validate dropdown selector
|
|
18
|
-
def valid_option_by? option_by
|
|
19
|
-
%w(text value index).include? option_by
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def validate_option_by option_by
|
|
23
|
-
raise "Invalid option by - #{option_by}" unless valid_option_by? option_by
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Return android device name and android version using adb command
|
|
27
|
-
def get_device_info
|
|
28
|
-
IO.popen('adb shell getprop ro.product.brand') { |f| $device = f.gets.chomp.upcase}
|
|
29
|
-
$device += ' '
|
|
30
|
-
IO.popen('adb shell getprop ro.product.model') { |f| $device += f.gets.chomp.upcase}
|
|
31
|
-
IO.popen('adb shell getprop ro.build.version.release') { |f| $os_version = f.gets.chomp.upcase}
|
|
32
|
-
return $device, $os_version
|
|
33
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'net/https'
|
|
2
|
-
require_relative 'required_files'
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def visit(page)
|
|
6
|
-
$driver.get(page)
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def click(locator_type, locator_name)
|
|
10
|
-
WAIT.until { $driver.find_element(:"#{locator_type}" => "#{locator_name}") }.click
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def displayed(locator_type, locator_name)
|
|
14
|
-
WAIT.until{ $driver.find_element(:"#{locator_type}" => "#{locator_name}") }.displayed?
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# method to validate dropdown selector
|
|
18
|
-
|
|
19
|
-
def check_element_on_page(locator_type, locator_name, scenario)
|
|
20
|
-
if scenario
|
|
21
|
-
if !displayed(locator_type, locator_name)
|
|
22
|
-
raise Failure, 'Element Not Present'
|
|
23
|
-
end
|
|
24
|
-
else
|
|
25
|
-
begin
|
|
26
|
-
if displayed(locator_type, locator_name)
|
|
27
|
-
raise 'Present'
|
|
28
|
-
end
|
|
29
|
-
rescue Exception => e
|
|
30
|
-
if e.message == 'Present'
|
|
31
|
-
raise Failure, 'Element Present'
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
data/template/my_first.feature
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'applenium'
|
data/template/support/env.rb
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'applenium'
|
|
3
|
-
|
|
4
|
-
$browser_type = ENV['BROWSER'] || 'ff'
|
|
5
|
-
$platform = ENV['PLATFORM'] || 'desktop'
|
|
6
|
-
$os_version = ENV['OS_VERSION']
|
|
7
|
-
$device_name = ENV['DEVICE_NAME']
|
|
8
|
-
$udid = ENV['UDID']
|
|
9
|
-
$app_path = ENV['APP_PATH']
|
|
10
|
-
|
|
11
|
-
validate_parameters $platform, $browser_type, $app_path
|
|
12
|
-
|
|
13
|
-
if $platform == 'android' or $platform == 'iOS'
|
|
14
|
-
|
|
15
|
-
if $browser_type == 'native'
|
|
16
|
-
$browser_type = "Browser"
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
if $platform == 'android'
|
|
20
|
-
$device_name, $os_version = get_device_info
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
desired_caps = {
|
|
24
|
-
caps: {
|
|
25
|
-
platformName: $platform,
|
|
26
|
-
browserName: $browser_type,
|
|
27
|
-
versionNumber: $os_version,
|
|
28
|
-
deviceName: $device_name,
|
|
29
|
-
udid: $udid,
|
|
30
|
-
app: ".//#{$app_path}"
|
|
31
|
-
},
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
begin
|
|
35
|
-
$driver = Appium::Driver.new(desired_caps).start_driver
|
|
36
|
-
rescue Exception => e
|
|
37
|
-
puts e.message
|
|
38
|
-
Process.exit(0)
|
|
39
|
-
end
|
|
40
|
-
else
|
|
41
|
-
begin
|
|
42
|
-
$driver = Selenium::WebDriver.for(:"#{$browser_type}")
|
|
43
|
-
$driver.manage().window().maximize()
|
|
44
|
-
rescue Exception => e
|
|
45
|
-
puts e.message
|
|
46
|
-
Process.exit(0)
|
|
47
|
-
end
|
|
48
|
-
end
|
data/template/support/hooks.rb
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#Cucumber provides a number of hooks which allow us to run blocks at various points in the Cucumber test cycle
|
|
2
|
-
|
|
3
|
-
Before do
|
|
4
|
-
# Do something before each scenario.
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
Before do |scenario|
|
|
8
|
-
# The +scenario+ argument is optional, but if you use it, you can get the title,
|
|
9
|
-
# description, or name (title + description) of the scenario that is about to be
|
|
10
|
-
# executed.
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
After do
|
|
14
|
-
# Do something after each scenario.
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
After do |scenario|
|
|
18
|
-
# Do something after each scenario.
|
|
19
|
-
# The +scenario+ argument is optional, but
|
|
20
|
-
# if you use it, you can inspect status with
|
|
21
|
-
# the #failed?, #passed? and #exception methods.
|
|
22
|
-
|
|
23
|
-
if(scenario.failed?)
|
|
24
|
-
#Do something if scenario fails.
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
#Tagged hooks
|
|
29
|
-
|
|
30
|
-
Before('@Ex_tag1, @Ex_tag2') do
|
|
31
|
-
# This will only run before scenarios tagged
|
|
32
|
-
# with @cucumis OR @sativus.
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
AfterStep('@Ex_tag1, @Ex_tag2') do
|
|
36
|
-
# This will only run after steps within scenarios tagged
|
|
37
|
-
# with @cucumis AND @sativus.
|
|
38
|
-
end
|