qat-web 6.0.3 → 7.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c0c42697ea27626ec6e4674fa4bfcb15157690095b7f95f17f70c8e011dac68
4
- data.tar.gz: a8e5c7815776b985bab6956db5d3c9050b4cbbf2e2a29bebde266ccd3401cbcf
3
+ metadata.gz: 0aadd76d0544542a1d7b1ec9a392ddbc5049fb6f137a8f9d65f816ad1a277281
4
+ data.tar.gz: 1947029c65e7cec67c756e23092b72d5da026bf400996c67f61d1d5c43ee2ca0
5
5
  SHA512:
6
- metadata.gz: 5b9b51572bca22fe718f253c153af8282674f588250ee7cb549e9c625c0ed20fc60752f239668e31c9981a1d13f0ed53987c59840f19e0668660af810ef9c60a
7
- data.tar.gz: ea161b61cc1e98e8daeeafdff7b0620d791e505886c26cd3384d18c26bd19ccb5376bf8a7b999102ac5c82b104f9f261a3ff41ca5bb5a2aa52590191c47a1d6b
6
+ metadata.gz: f23e24e6e48a67fb47cb9cbf9ece4f9ff2c6da5ee0e0cc5474a2c3a590908dfd740c3369500741798013a0f73fec4ea612ce1aead9d76c654ba0bca9b9dda867
7
+ data.tar.gz: af97afa92c26af6a3153099b4698373865659aa5155a6e82c1a92ed3b6d9bfcab49a78324bc955db1f92f625600e764cf3b0fc310897a1271be01fa7a532ed46
data/lib/qat/cli.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'little-plugger'
2
+
3
+ module QAT
4
+ #Module for CLI functions
5
+ #@since 6.1.0
6
+ module CLI
7
+ #Module as namespace for plugin definition
8
+ #@since 6.1.0
9
+ module Plugins
10
+ #Placeholder
11
+ end
12
+ # @!parse extend LittlePlugger
13
+ send :extend, LittlePlugger( :path => 'qat/cli/plugins', :module => ::QAT::CLI::Plugins )
14
+
15
+ #Lists all registered extentions/plugins
16
+ #@since 6.1.0
17
+ def self.list_extentions
18
+ plugins.keys.map(&:to_s).sort
19
+ end
20
+
21
+ #Call add_module in a given plugin.
22
+ #@param mod [String,Symbol] name of the plugin to call
23
+ #@param stdout [IO] stdout stream
24
+ #@param opts [Hash] options hash
25
+ #@raise ArgumentError When module does not exist
26
+ #@since 6.1.0
27
+ def self.add_module mod, stdout, opts
28
+ raise ArgumentError.new "Module #{mod} is not a plugin!" unless has_module? mod
29
+
30
+ loaded_mod = plugins[mod.to_sym]
31
+
32
+ if loaded_mod.respond_to? :add_module
33
+ meth = loaded_mod.method :add_module
34
+ unless meth.arity == 2 || meth.arity < 0
35
+ raise ArgumentError.new "Invalid implementation of add_module in #{mod}: should have 2 parameters: stdout, opts"
36
+ end
37
+ meth.call stdout, opts
38
+ else
39
+ stdout.puts "Nothing to add in #{mod}"
40
+ end
41
+ end
42
+
43
+
44
+ #Check if a plugin exists
45
+ #@param mod [String,Symbol] name of the plugin to call
46
+ #@return [true,false] true if the plugin exists
47
+ #@since 6.1.0
48
+ def self.has_module? mod
49
+ return plugins.has_key? mod.to_sym
50
+ end
51
+ end
52
+ end
@@ -1,7 +1,26 @@
1
- require_relative '../../web/version'
1
+ require_relative '../../web/generator'
2
2
 
3
3
  #Plugin for CLI functions
4
- #@since 1.0.0
5
- module QAT::CLI::Plugins::Web
4
+ #@since 6.1.0
5
+ module QAT
6
+ #CLI module from QAT::Web.
7
+ #@since 6.1.0
8
+ module CLI
9
+ #Plugin namespace for CLI module from QAT::Web.
10
+ #@since 6.1.0
11
+ module Plugins
12
+ #Plugin for CLI functions
13
+ #@since 6.1.0
14
+ module Web
6
15
 
16
+ #Function for adding the Logger module to a project. Just used for testing, does nothing.
17
+ #@param stdout [IO] Stdout stream
18
+ #@param opts [Hash] Options hash
19
+ #@since 6.1.0
20
+ def self.add_module stdout, opts
21
+ QAT::Web::Generator.add_module(stdout, opts)
22
+ end
23
+ end
24
+ end
25
+ end
7
26
  end
@@ -17,23 +17,36 @@ module QAT::Web
17
17
  #@return [String/NilClass] File path to where the HTML dump file was saved or nil if the browser doesn't support HTML dumps
18
18
  #@since 1.0.0
19
19
  def take_html_dump(page=Capybara.current_session, path=html_dump_path)
20
- log.info { "Saving HTML dump to #{path}" }
21
20
  raise ArgumentError.new "File #{path} already exists! Choose another filename" if ::File.exists? path
22
- path = page.save_page path
21
+ log.info { "Saving HTML dump to #{path}" }
22
+ path = read_html_dump page ,path
23
23
  log.info { "HTML dump available" }
24
- ::File.basename(path)
24
+ path
25
25
  rescue Capybara::NotSupportedByDriverError
26
26
  log.warn { "Driver #{page.mode} does not support HTML dumps!" }
27
27
  return nil
28
28
  end
29
29
 
30
+
31
+ ##Helper for reading file, in cucumber 6 this could be reverted to path directly
32
+ def read_html_dump page, dump_path
33
+ file = page.save_page dump_path
34
+ dump_path_read = File.open file
35
+ dump_path_read.read
36
+ end
37
+
30
38
  #Default HTML dump path. Can be set with {#html_dump_path=}.
31
39
  #@return [String] HTML dump path
32
40
  #@since 1.0.0
41
+
33
42
  def html_dump_path
34
43
  @html_dump_path || ::File.join('public', "browser_#{Time.new.strftime("%H%M%S%L")}.html")
35
44
  end
36
45
 
46
+ def html_dump_filename
47
+ File.basename(@html_dump_path)
48
+ end
49
+
37
50
  #Set new default HTML dump path.
38
51
  #@param path [String] HTML dump path
39
52
  #@since 1.0.0
@@ -16,17 +16,29 @@ module QAT::Web
16
16
  #@param path [String] File path to save screenshot file
17
17
  #@return [String/NilClass]File path to where the screenshot file was saved or nil if the browser doesn't support screenshots
18
18
  #@since 1.0.0
19
- def take_screenshot page=Capybara.current_session, path=screenshot_path
20
- log.info {"Saving screenshot to #{path}"}
19
+ def take_screenshot page = Capybara.current_session , path = screenshot_path
20
+ log.info { "Saving screenshot to #{path}" }
21
21
  raise ArgumentError.new "File #{path} already exists! Choose another filename" if ::File.exists? path
22
- path = page.save_screenshot path
23
- log.info {"Screenshot available"}
22
+ path = read_screenshot_file page, path
23
+ log.info { "Screenshot available" }
24
24
  path
25
25
  rescue Capybara::NotSupportedByDriverError
26
26
  log.warn {"Driver #{page.mode} does not support screenshots!"}
27
27
  return nil
28
28
  end
29
29
 
30
+ ##Helper for reading file, in cucumber 6 this could be reverted to path directly
31
+ def read_screenshot_file page, image_path
32
+ file = page.save_page image_path
33
+ image_path_read = File.open file
34
+ image_path_read.read
35
+ end
36
+
37
+
38
+ def screenshot_filename
39
+ File.basename(@screenshot_path)
40
+ end
41
+
30
42
  #Default screenshot path. Can be set with {#screenshot_path=}.
31
43
  #@return [String] Screenshot path
32
44
  #@since 1.0.0
@@ -0,0 +1,57 @@
1
+ require_relative '../../../lib/qat/web/version'
2
+ require 'fileutils'
3
+ require 'gemnasium/parser'
4
+
5
+ module QAT::Web
6
+ #Module for the various generators used in the CLI utility
7
+ #@since 6.1.0
8
+ module Generator
9
+ include FileUtils
10
+ extend FileUtils
11
+ # Adds a files QAT Web module to the current project
12
+ def add_module(stdout, opts)
13
+ stdout.puts "Adding files to project" if opts[:verbose]
14
+
15
+ # Read GemFile of new project
16
+ path = File.join(Dir.pwd, 'Gemfile')
17
+ has_qatweb = verify_gems path, 'qat-web', verbose: opts[:verbose]
18
+ if has_qatweb
19
+ puts "Module already integrated"
20
+ else
21
+ add_gem_dependency path, 'qat-web', verbose: opts[:verbose], version: QAT::Web::VERSION
22
+ add_gem_dependency path, 'headless', verbose: opts[:verbose]
23
+ add_gem_dependency path, 'selenium-webdriver', verbose: opts[:verbose]
24
+ cp_r ::File.join(::File.dirname(__FILE__), 'generator', 'project', '.'), Dir.pwd, opts
25
+ end
26
+ end
27
+
28
+ def verify_gems (gemfile_path, gem, opts = {})
29
+ file = File.read(gemfile_path)
30
+ gemfile = Gemnasium::Parser.gemfile(file)
31
+ dependencies = gemfile.dependencies
32
+ found_gem = dependencies.find {|i| i.name == gem}
33
+ puts "Found gem: #{found_gem}"
34
+ puts "gem #{gem} found? #{!found_gem.nil?}" if opts[:verbose]
35
+
36
+ if found_gem
37
+ return true
38
+ else
39
+ return false
40
+ end
41
+ end
42
+
43
+ def add_gem_dependency (gemfile_path, gem, opts = {})
44
+ version = opts[:version]
45
+ line = "\n\ngem '#{gem}'#{version ? ", '>= #{version}'" : ''}"
46
+ puts "adding dependencies #{gem} to Gemfile" if opts[:verbose]
47
+ write_to_gemfile gemfile_path, line
48
+ end
49
+
50
+
51
+ def write_to_gemfile filename, line
52
+ ::File.write(filename, line, mode: 'a')
53
+ end
54
+
55
+ module_function :add_module, :write_to_gemfile, :add_gem_dependency, :verify_gems
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ firefox:
2
+ browser: firefox
3
+ screen: screen_1080p
4
+ properties:
5
+ geo.enabled: false
@@ -0,0 +1,4 @@
1
+ locators:
2
+ locator_name_example:
3
+ xpath: .//*[@name='q']
4
+ wait: timeouts.browser.medium
@@ -0,0 +1,4 @@
1
+ locators:
2
+ locator_name_example:
3
+ xpath: .//a[@title='selector_example']
4
+ wait: timeouts.browser.medium
@@ -0,0 +1,10 @@
1
+ screen_1080p: &screen_1080p
2
+ resolution:
3
+ width: 1920
4
+ height: 1080
5
+ video:
6
+ provider: ffmpeg
7
+ log_file_path: <%= File.join 'public', 'video.log' %>
8
+ codec: libx264
9
+ frame_rate: 12
10
+ extra: -pix_fmt yuvj420p
@@ -0,0 +1,7 @@
1
+ browser:
2
+ small: 5
3
+ medium: 15
4
+ big: 30
5
+ huge: 60
6
+ go_grab_a_coffee: 120
7
+ bathroom_break: 360
@@ -0,0 +1,7 @@
1
+ When(/^I navigate to home page$/) do
2
+ browser.navigate_home!
3
+ end
4
+
5
+ Then(/^I can interact with home page$/) do
6
+ browser.input_search "Test Automation"
7
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding : utf-8 -*-
2
+ ############################################
3
+ # Requires for your code libraries go here #
4
+ ############################################
5
+ require 'selenium-webdriver'
6
+ require 'qat/cucumber'
7
+ require 'qat/configuration'
8
+ require 'qat/web'
9
+ require 'qat/web/cucumber'
10
+ require_relative '../../lib/web/world'
11
+ require 'qat/core_ext/integer'
12
+
13
+ World ProjectName::Web::World
14
+
15
+ ENV['FIREFOX_PATH']&.tap do |path|
16
+ Selenium::WebDriver::Firefox::Binary.path = path
17
+ end
@@ -0,0 +1,11 @@
1
+ @epic#1 @feature#2 @user_story#3 @dummy_feature
2
+ Feature: some feature
3
+ In order to do something
4
+ As someone
5
+ I want to specify scenarios
6
+
7
+
8
+ @test#10 @dummy_test
9
+ Scenario: Navigate to google page
10
+ When I navigate to home page
11
+ Then I can interact with home page
@@ -0,0 +1,2 @@
1
+ require_relative 'web/pages'
2
+ require_relative 'web/page_manager'
@@ -0,0 +1,11 @@
1
+ require_relative 'pages'
2
+ require 'qat/web/page_manager'
3
+
4
+ #Project name Module
5
+ module ProjectName::Web
6
+ #Class PageManager
7
+ class PageManager < QAT::Web::PageManager
8
+ manages ProjectName::Web::Pages::Base
9
+ initial_page ProjectName::Web::Pages::Blank
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ require_relative 'pages/base'
2
+ require_relative 'pages/blank'
3
+ require_relative 'pages/home'
@@ -0,0 +1,27 @@
1
+ require 'capybara/dsl'
2
+ require 'qat/logger'
3
+ require 'qat/configuration'
4
+ require 'qat/web/page'
5
+ require 'qat/web/finders'
6
+
7
+ #Project name Module
8
+ module ProjectName
9
+ #Web name Module
10
+ module Web
11
+ #Page name Module
12
+ module Pages
13
+ #Class base
14
+ class Base < QAT::Web::Page
15
+ include Capybara::DSL
16
+ include QAT::Logger
17
+ include QAT::Web::Finders
18
+
19
+ # Action to navigate to your home page
20
+ action :navigate_home!, returns: [ProjectName::Web::Pages::Base] do
21
+ visit 'https://www.google.com'
22
+ ProjectName::Web::Pages::Home.new
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ require_relative 'base'
2
+
3
+ #Blank class
4
+ class ProjectName::Web::Pages::Blank < ProjectName::Web::Pages::Base
5
+ end
@@ -0,0 +1,35 @@
1
+ require_relative 'base'
2
+
3
+ #Project name Module
4
+ module ProjectName
5
+ #Web name Module
6
+ module Web
7
+ #Page Object Pages
8
+ module Pages
9
+ #Home page
10
+ class Home < ProjectName::Web::Pages::Base
11
+ include QAT::Logger
12
+
13
+ elements_config QAT.configuration.dig(:qat, :web, :home)
14
+
15
+ web_elements :locator_name_example
16
+
17
+ def initialize
18
+ raise HomePageNotLoaded.new 'Home page was not loaded!' unless has_selector? *selector_locator_name_example
19
+ log.info "Loaded home page with URL: #{current_url}"
20
+ end
21
+
22
+ #Introduce text on search box
23
+ def input_search search_text
24
+ locator_name_example.set search_text
25
+ end
26
+
27
+ private
28
+
29
+ #Exception class error
30
+ class HomePageNotLoaded < QAT::Web::Error
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'page_manager'
2
+
3
+ QAT::Web::Browser::AutoLoad.load_browsers!
4
+ QAT::Web::Screen::AutoLoad.load_screens!
5
+
6
+ #Project name Module
7
+ module ProjectName
8
+ #Web name Module
9
+ module Web
10
+ #World name Module
11
+ module World
12
+ #Initialise browser
13
+ def browser
14
+ unless @browser
15
+ QAT::Web::Browser::Factory.for :firefox
16
+ @browser = ProjectName::Web::PageManager.new
17
+ end
18
+ @browser
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -15,7 +15,7 @@ After do |scenario|
15
15
  if scenario.failed?
16
16
  if QAT::Web::Exceptions::HTML_DUMP.any? { |exception| scenario.exception.kind_of?(exception) }
17
17
  # Embeds an existing HTML dump to Cucumber's HTML report
18
- embed(QAT::Web::Browser::HTMLDump.take_html_dump, 'text/plain', 'HTML dump')
18
+ attach(QAT::Web::Browser::HTMLDump.take_html_dump, 'text/html')
19
19
  end
20
20
  end
21
21
  end
@@ -14,7 +14,7 @@ end
14
14
  After do |scenario|
15
15
  if scenario.failed?
16
16
  if QAT::Web::Exceptions::SCREENSHOT.any? { |exception| scenario.exception.kind_of?(exception) }
17
- embed QAT::Web::Browser::Screenshot.take_screenshot, 'image/png', 'Screenshot'
17
+ attach QAT::Web::Browser::Screenshot.take_screenshot, 'image/png'
18
18
  end
19
19
  end
20
20
  end
@@ -4,6 +4,6 @@ module QAT
4
4
  #@since 1.0.0
5
5
  module Web
6
6
  # Represents QAT-Web's version
7
- VERSION = '6.0.3'
7
+ VERSION = '7.0.0.rc.1'
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qat-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.3
4
+ version: 7.0.0.rc.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - QAT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2021-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: qat-cucumber
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '6.0'
19
+ version: 7.0.3
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '6.0'
26
+ version: 7.0.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: qat-devel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '6.0'
33
+ version: '8.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '6.0'
40
+ version: '8.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: headless
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -126,14 +126,14 @@ dependencies:
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '6.0'
129
+ version: '8.0'
130
130
  type: :runtime
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '6.0'
136
+ version: '8.0'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: little-plugger
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -196,6 +196,20 @@ dependencies:
196
196
  - - ">="
197
197
  - !ruby/object:Gem::Version
198
198
  version: '0'
199
+ - !ruby/object:Gem::Dependency
200
+ name: gemnasium-parser
201
+ requirement: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ type: :runtime
207
+ prerelease: false
208
+ version_requirements: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
199
213
  description: |2
200
214
  QAT-Web is a browser controller for Web testing, with support for various browsers and webdrivers.
201
215
  Includes various classes for easier planning and implementation of web interactions, using the Page Objects Pattern.
@@ -209,6 +223,7 @@ files:
209
223
  - lib/capybara/core_ext/node/element.rb
210
224
  - lib/capybara/core_ext/selenium/node.rb
211
225
  - lib/headless/core_ext/random_display.rb
226
+ - lib/qat/cli.rb
212
227
  - lib/qat/cli/plugins/web.rb
213
228
  - lib/qat/web.rb
214
229
  - lib/qat/web/browser.rb
@@ -238,6 +253,22 @@ files:
238
253
  - lib/qat/web/error/enrichment.rb
239
254
  - lib/qat/web/exceptions.rb
240
255
  - lib/qat/web/finders.rb
256
+ - lib/qat/web/generator.rb
257
+ - lib/qat/web/generator/project/config/common/browsers.yml
258
+ - lib/qat/web/generator/project/config/common/qat/web/home.yml
259
+ - lib/qat/web/generator/project/config/common/qat/web/page.yml
260
+ - lib/qat/web/generator/project/config/common/screens.yml
261
+ - lib/qat/web/generator/project/config/common/timeouts.yml
262
+ - lib/qat/web/generator/project/features/step_definitions/steps.rb
263
+ - lib/qat/web/generator/project/features/support/env_qat_web.rb
264
+ - lib/qat/web/generator/project/features/web_example.feature
265
+ - lib/qat/web/generator/project/lib/web.rb
266
+ - lib/qat/web/generator/project/lib/web/page_manager.rb
267
+ - lib/qat/web/generator/project/lib/web/pages.rb
268
+ - lib/qat/web/generator/project/lib/web/pages/base.rb
269
+ - lib/qat/web/generator/project/lib/web/pages/blank.rb
270
+ - lib/qat/web/generator/project/lib/web/pages/home.rb
271
+ - lib/qat/web/generator/project/lib/web/world.rb
241
272
  - lib/qat/web/hooks/common.rb
242
273
  - lib/qat/web/hooks/har_exporter.rb
243
274
  - lib/qat/web/hooks/html_dump.rb
@@ -264,15 +295,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
264
295
  requirements:
265
296
  - - "~>"
266
297
  - !ruby/object:Gem::Version
267
- version: '2.4'
298
+ version: '2.5'
268
299
  required_rubygems_version: !ruby/object:Gem::Requirement
269
300
  requirements:
270
- - - ">="
301
+ - - ">"
271
302
  - !ruby/object:Gem::Version
272
- version: '0'
303
+ version: 1.3.1
273
304
  requirements: []
274
- rubyforge_project:
275
- rubygems_version: 2.7.7
305
+ rubygems_version: 3.0.8
276
306
  signing_key:
277
307
  specification_version: 4
278
308
  summary: QAT-Web is a browser controller for Web testing