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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -0
  3. data/CONTRIBUTING.md +31 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +22 -0
  6. data/README.md +31 -0
  7. data/applenium.gemspec +25 -0
  8. data/bin/applenium +6 -26
  9. data/features/cucumber_template.feature +7 -0
  10. data/features/step_definitions/all_steps.rb +11 -0
  11. data/features/support/env.rb +6 -0
  12. data/features/support/support_code.rb +0 -0
  13. data/lib/applenium/mobile/mobile_methods.rb +2 -0
  14. data/lib/applenium/{methods → mobile}/required_files.rb +3 -3
  15. data/lib/applenium/mobile_steps.rb +13 -0
  16. data/lib/applenium/version.rb +1 -1
  17. data/lib/applenium/web/required_files.rb +8 -0
  18. data/lib/applenium/web/web_methods.rb +2 -0
  19. data/lib/applenium/web_steps.rb +13 -0
  20. data/lib/applenium.rb +5 -1
  21. data/scaffold/.relish +2 -0
  22. data/scaffold/.rubocop.yml +43 -0
  23. data/scaffold/.ruby-version +1 -0
  24. data/scaffold/.travis.yml +16 -0
  25. data/scaffold/.yard.yml +10 -0
  26. data/scaffold/Gemfile +16 -0
  27. data/scaffold/README.md +27 -0
  28. data/scaffold/browser.json +14 -0
  29. data/scaffold/ci_script +15 -0
  30. data/scaffold/cucumber.yml +10 -0
  31. data/scaffold/features/google.feature +7 -0
  32. data/scaffold/features/pages/Abstract.rb +14 -0
  33. data/scaffold/features/pages/HomePage.rb +22 -0
  34. data/scaffold/features/step_definitions/google_steps.rb +3 -0
  35. data/scaffold/features/support/env.rb +107 -0
  36. data/scaffold/features/support/helpers.erb +6 -0
  37. data/scaffold/features/support/hooks.rb +18 -0
  38. data/scaffold/features/support/responsive.rb +19 -0
  39. data/scaffold/lib/project/version.erb +3 -0
  40. data/scaffold/lib/project.erb +2 -0
  41. data/scaffold/package.json +11 -0
  42. data/scaffold/rake_tasks/cucumber.rb +8 -0
  43. data/scaffold/rake_tasks/cuke_sniffer.rb +4 -0
  44. data/scaffold/rake_tasks/rspec.rb +12 -0
  45. data/scaffold/rake_tasks/rubocop.rb +12 -0
  46. data/scaffold/rake_tasks/yard.rb +11 -0
  47. data/scaffold/spec/spec_helper.rb +8 -0
  48. metadata +76 -23
  49. data/bin/generate.rb +0 -20
  50. data/bin/helper.rb +0 -51
  51. data/lib/applenium/applenium_steps.rb +0 -14
  52. data/lib/applenium/methods/error_handling_methods.rb +0 -87
  53. data/lib/applenium/methods/misc_methods.rb +0 -33
  54. data/lib/applenium/methods/web_methods.rb +0 -35
  55. data/template/my_first.feature +0 -7
  56. data/template/step_definitions/custom_steps.rb +0 -1
  57. data/template/support/env.rb +0 -48
  58. data/template/support/hooks.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2069cc18508e87fdf6cd4383d2774f3256c62795
4
- data.tar.gz: bc2e8bae206aeb8c2ce6c29a41078d16752fd208
3
+ metadata.gz: 8fa9d6f48690aea8ce8b2b867394ab2330623c48
4
+ data.tar.gz: 2cdd9dde248b008604c5ecb0442367172a0c6652
5
5
  SHA512:
6
- metadata.gz: 5e4a957b0a77bb6c109675a45d05ed521bda58b8aeb3e736b9640432dfb456d8de60338e423ce0ac2638241697ab830af3b0f3c2e4fb45a8f1fdd2638d2a0b8c
7
- data.tar.gz: c3e1deaa1aa4d740fa74b76877edafa9cf2720370fa23de92d7653a534055204c3154a46f6f6ada55dc10ef980ac0de87a1682efaf0c5d23da7d1d92c64a125a
6
+ metadata.gz: 42269de300920615a809787b5016f3a4a1b31280450f6c21852e9ec06aee8fafd152e361889b2f94517c42521a4a9427090097455c164317044193a60baf802b
7
+ data.tar.gz: 79a676dc53197fe2ca176b4227168a1f2bd34904786fb27627b63821888d33f109f4af1704315a00e6bdf72e14e081c1d9dbca2e3dc7b8b84503f5ec502e2e7d
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ pkg/*
2
+ tmp/*
3
+ doc/*
4
+ *.gem
5
+ .bundle
6
+ .yardo
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
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+ gemspec
3
+
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
- require_relative 'helper.rb'
4
- require_relative 'generate.rb'
5
- require 'applenium/version'
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
- @features_dir = File.join(FileUtils.pwd, "features")
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)
@@ -0,0 +1,7 @@
1
+ Feature: Generate cucumber template
2
+
3
+ Scenario: Generate Cucumber
4
+
5
+ Given I have empty directory
6
+ When I run Applenium
7
+ Then I shouls see all the files and directories are created
@@ -0,0 +1,11 @@
1
+ Given(/^I have empty directory$/) do
2
+
3
+ end
4
+
5
+ When(/^I run Applenium$/) do
6
+
7
+ end
8
+
9
+ Then(/^I shouls see all the files and directories are created$/) do
10
+
11
+ end
@@ -0,0 +1,6 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ require "aruba"
5
+
6
+ require 'applenium'
File without changes
@@ -0,0 +1,2 @@
1
+ require 'net/https'
2
+ require_relative 'required_files'
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Applenium
2
- VERSION = '0.0.3'
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'cucumber'
3
+ require 'capybara'
4
+ require 'rspec'
5
+ require 'selenium-webdriver'
6
+ require 'open-uri'
7
+ require 'rbconfig'
8
+ include RbConfig
@@ -0,0 +1,2 @@
1
+ require 'net/https'
2
+ require_relative 'required_files'
@@ -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
@@ -1 +1,5 @@
1
- Dir[File.dirname(__FILE__) + '/applenium/*.rb'].each { |file| require file }
1
+ Dir[File.dirname(__FILE__) + '/applenium/*.rb'].each {|file| require file }
2
+
3
+ module Applenium
4
+
5
+ end
data/scaffold/.relish ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ api_token: your_token
@@ -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
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ rvm:
5
+ - 2.0.0
6
+
7
+ before_script: 'bundle install'
8
+ script: 'bundle exec rake features'
9
+
10
+ branches:
11
+ only:
12
+ - master
13
+
14
+ notifications:
15
+ email:
16
+ - your_email
@@ -0,0 +1,10 @@
1
+ --- !map:SymbolHash
2
+ :load_plugins: true
3
+ :ignored_plugins: []
4
+
5
+ :autoload_plugins: []
6
+
7
+ :safe_mode: false
8
+
9
+ :"yard-cucumber":
10
+ menus: [ 'features', 'directories', 'tags', 'steps', 'step definitions' ]
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'
@@ -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
+
@@ -0,0 +1,14 @@
1
+ {
2
+ "ios_iphone_6": {
3
+ "device": "iPhone 5",
4
+ "browserName": "iPhone",
5
+ "os": "ios",
6
+ "os_version": "6.0"
7
+ },
8
+ "osx_firefox": {
9
+ "browser": "firefox",
10
+ "browser_version": "15.0",
11
+ "os": "OS X",
12
+ "os_version": "Snow Leopard"
13
+ }
14
+ }
@@ -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,7 @@
1
+ Feature: Google Search to explore Applenium
2
+
3
+
4
+ Scenario: View home page
5
+ Given I am on "http://www.google.com"
6
+ When I fill in "q" with "shashi"
7
+ Then I should see "Sign in"
@@ -0,0 +1,14 @@
1
+ class Abstract
2
+
3
+ def initialize(session)
4
+ @session = Capybara.current_session
5
+ end
6
+
7
+ def your_abstracted_method1
8
+ #your code goes here
9
+ end
10
+
11
+ def your_abstracted_method2
12
+ #your code goes here
13
+ end
14
+ end
@@ -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,3 @@
1
+ require 'applenium'
2
+
3
+ # Implement your custom steps here if not in the Applenium
@@ -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,6 @@
1
+ module <%= project_name.camelize %>
2
+ module CucumberHelpers
3
+ end
4
+ end
5
+
6
+ World(<%= project_name.camelize %>::CucumberHelpers)
@@ -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,3 @@
1
+ module <%= project_name.camelize %>
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ module <%= project_name.camelize %>
2
+ end
@@ -0,0 +1,11 @@
1
+ {
2
+ "version": "0.0.0",
3
+ "description": "Applenium nodeJS modules",
4
+ "dependencies": {
5
+ "webdriverjs" : "*",
6
+ "appium": "*"
7
+ },
8
+
9
+ "author": "Shashikant Jagtap",
10
+ "license": "MIT"
11
+ }
@@ -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,4 @@
1
+ task :cuke_sniffer do
2
+ sh 'cd features'
3
+ sh 'bundle exec cuke_sniffer'
4
+ end
@@ -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,12 @@
1
+ require 'rubocop/rake_task'
2
+
3
+ #desc "Run Rubocop"
4
+
5
+ #Rubocop::RakeTask.new(:rubocop_rake) do |task|
6
+ # task.patterns = ['features/**/*.rb']
7
+ #end
8
+
9
+ task :rubocop do
10
+ sh 'bundle exec rubocop'
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
+
@@ -0,0 +1,8 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ require 'rspec'
5
+
6
+ RSpec.configure do |config|
7
+ config.fail_fast = true
8
+ end
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.3
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: selenium-webdriver
34
+ name: capybara
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ~>
38
38
  - !ruby/object:Gem::Version
39
- version: 2.44.0
39
+ version: 2.4.4
40
40
  - - '>='
41
41
  - !ruby/object:Gem::Version
42
- version: 2.41.0
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.44.0
49
+ version: 2.4.4
50
50
  - - '>='
51
51
  - !ruby/object:Gem::Version
52
- version: 2.41.0
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: appium_lib
74
+ name: selenium-webdriver
55
75
  requirement: !ruby/object:Gem::Requirement
56
76
  requirements:
57
77
  - - ~>
58
78
  - !ruby/object:Gem::Version
59
- version: 4.1.0
79
+ version: 2.44.0
60
80
  - - '>='
61
81
  - !ruby/object:Gem::Version
62
- version: 4.0.0
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: 4.1.0
89
+ version: 2.44.0
70
90
  - - '>='
71
91
  - !ruby/object:Gem::Version
72
- version: 4.0.0
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
- - bin/generate.rb
82
- - bin/helper.rb
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/applenium_steps.rb
85
- - lib/applenium/methods/error_handling_methods.rb
86
- - lib/applenium/methods/misc_methods.rb
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
- - template/my_first.feature
91
- - template/step_definitions/custom_steps.rb
92
- - template/support/env.rb
93
- - template/support/hooks.rb
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: 1.9.3
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
@@ -1,7 +0,0 @@
1
- Feature: Test feature
2
-
3
- Scenario: Test Lazycuke
4
-
5
- Given I am on "www.google.com"
6
- When I fill in "q" with "shashi"
7
- Then I should see "Sign in"
@@ -1 +0,0 @@
1
- require 'applenium'
@@ -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
@@ -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