generic_test 0.1.10 → 0.1.11

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: 3cd6c9a3fb72be1be7624ef067e5240d37cd95607a62f1a18214de73e589be63
4
- data.tar.gz: ee175d1814512d5dfb07582dd733e06525e7b3c324c42a9922e6eb50cf69b33f
3
+ metadata.gz: 9e9dabdf7bdc04b3967c77b109f7ce9ee0893896c31d98c05f54a732e9d7f513
4
+ data.tar.gz: 715dc1bb7195c5dfb5eab9d5da467fdbbd5d54c431151876397141ed4bed9cbb
5
5
  SHA512:
6
- metadata.gz: 8c6f165cba804d210657ef544a83da5de6bb21b664ea446b18f87ba817b0fdcc29ca80883518427a1ffc5b3ea4117271ecf65290bbdb0134115657577da373d3
7
- data.tar.gz: a960a256ecbd5d8c951458936323c8e8a55ef5c4855a614f21fa29adda402b191e265adfe3de7ba62700568ee831bee9b3c2ba92efd9be2e1b90b24a8620ecd8
6
+ metadata.gz: ce37d41116ea08457eeb93d247b517f834d7cc790c1bd43b21457f16cc221af8f82d3cc3d8093aff30682237d0d120e36ab407ef56e0fcbbbcb9a166f6777b4c
7
+ data.tar.gz: 4769b1befffe34c5798bf485bc1ff717b86b50f8cb5d26e145d43251ed1f84c737d50dba925df7d76953e7f11e2115588fbebb962097b5c74cd6536253af590c
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ Gemfile.lock
15
15
 
16
16
  # rspec failure tracking
17
17
  .rspec_status
18
+ generic_test.page.yml
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ Version 0.1.11
2
+ * Enhancement
3
+ * Spell check based on text of page, not HTML.
4
+ * Reject links that start with 'javascript:'
5
+ * Initial handling of logging into Login page with generic identifiers
6
+
1
7
  Version 0.1.10
2
8
  * Bug fix
3
9
  * Add custom file implementing mock of what's needed for RSpecHtmlReporter
data/generic_test.gemspec CHANGED
@@ -40,4 +40,5 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency 'thor' # Command line utility
41
41
  spec.add_dependency 'watir' # UI interaction
42
42
  spec.add_dependency 'webdrivers' # Download chromedriver automatically
43
+ spec.add_dependency 'yamler'
43
44
  end
@@ -7,6 +7,7 @@ module GenericTest
7
7
  attr_accessor :emails
8
8
  attr_accessor :url
9
9
  attr_accessor :html
10
+ attr_accessor :text
10
11
  attr_accessor :title
11
12
 
12
13
  # Store state of page when it is loaded
@@ -15,10 +16,11 @@ module GenericTest
15
16
  self.emails, self.links = browser.links.partition do |link|
16
17
  link.href.start_with?('mailto:')
17
18
  end
18
- links.reject! { |link| link.href.empty? }
19
+ links.reject! { |link| link.href.empty? || link.href.start_with?('javascript:') }
19
20
  emails.collect! { |link| link.href.split(':').last }
20
21
  self.url = browser.url
21
22
  self.html = browser.html
23
+ self.text = browser.text
22
24
  self.title = browser.title
23
25
  puts "Found #{links.count} links, #{emails.count} emails at #{url} (#{title})"
24
26
  end
@@ -1,4 +1,45 @@
1
- # One file to require gem and set things up
1
+ # frozen_string_literal: true
2
+
3
+ # One file to require gem and set things up, arriving at page to check
2
4
  require 'generic_test'
3
5
 
4
- GenericTest.setup
6
+ # @return [String] Generic Test URL to login before arriving at PAGE_URL to test.
7
+ # Needs GT_USERNAME and GT_PASSWORD to be used
8
+ GT_LOGIN_URL = 'GT_LOGIN_URL'
9
+ GT_USERNAME = 'GT_USERNAME'
10
+ GT_PASSWORD = 'GT_PASSWORD'
11
+ GT_PAGE_SETTING_FILE = 'generic_test.page.yml'
12
+
13
+ ENV['HEADLESS'] ||= 'true'
14
+ ENV['PAGE_NUM'] ||= '1'
15
+ browser_args = %w[--disable-popup-blocking --no-sandbox --disable-dev-shm-usage]
16
+ browser_args << '--headless' if ENV['HEADLESS'] == 'true'
17
+
18
+ GenericTest.browser = Watir::Browser.new :chrome, args: browser_args
19
+
20
+ raise 'PAGE_URL environment variable not set' unless ENV['PAGE_URL']
21
+
22
+ require 'yamler'
23
+ if File.exist?(GT_PAGE_SETTING_FILE) && !File.read(GT_PAGE_SETTING_FILE).empty?
24
+ gt_page_settings = Yamler.load 'generic_test.page.yml'
25
+ if gt_page_settings['login']
26
+ ENV[GT_USERNAME] = gt_page_settings['login']['username']
27
+ ENV[GT_PASSWORD] = gt_page_settings['login']['password']
28
+ ENV[GT_LOGIN_URL] = gt_page_settings['login']['url']
29
+ end
30
+ end
31
+
32
+ browser = GenericTest.browser
33
+ if ENV[GT_LOGIN_URL] && ENV[GT_USERNAME] && ENV[GT_PASSWORD]
34
+ browser.goto ENV[GT_LOGIN_URL]
35
+ browser.text_field(xpath: "//input[@id=(//label[text()='Username']/@for)]|//input[@*='username']").set ENV[GT_USERNAME]
36
+ browser.text_field(xpath: "//input[@id=(//label[text()='Password']/@for)]|//input[@*='password']").set ENV[GT_PASSWORD]
37
+ login_button = browser.button(xpath: "//*[@type='submit']|//*[@*='Login']")
38
+ login_button.click
39
+ login_button.wait_while(&:present?)
40
+ puts "Login through #{ENV[GT_LOGIN_URL]} successful!"
41
+ end
42
+
43
+ browser.goto ENV['PAGE_URL']
44
+ sleep 2.5 # Give a bit of time for page to load
45
+ GenericTest.pages << GenericTest::Page.new(browser)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GenericTest
4
- VERSION = '0.1.10'
4
+ VERSION = '0.1.11'
5
5
  end
data/lib/generic_test.rb CHANGED
@@ -18,20 +18,5 @@ module GenericTest
18
18
  attr_accessor :browser
19
19
  attr_accessor :pages
20
20
  attr_accessor :only_javascript
21
-
22
- def setup
23
- ENV['HEADLESS'] ||= 'true'
24
- ENV['PAGE_NUM'] ||= '1'
25
- browser_args = %w[--disable-popup-blocking --no-sandbox --disable-dev-shm-usage]
26
- browser_args << '--headless' if ENV['HEADLESS'] == 'true'
27
-
28
- GenericTest.browser = Watir::Browser.new :chrome, args: browser_args
29
-
30
- raise 'PAGE_URL environment variable not set' unless ENV['PAGE_URL']
31
-
32
- browser = GenericTest.browser
33
- browser.goto ENV['PAGE_URL']
34
- GenericTest.pages << GenericTest::Page.new(browser)
35
- end
36
21
  end
37
22
  end
@@ -23,7 +23,7 @@ RSpec.describe "#{page.title} Emails are valid" do
23
23
  end
24
24
 
25
25
  RSpec.describe "#{page.title} Page content" do
26
- spellcheck_report = SpellCheck::ProofReader.check(page.html)
26
+ spellcheck_report = SpellCheck::ProofReader.check(page.text)
27
27
  context 'does not have common spelling mistakes' do
28
28
  it 'has no mistakes' do
29
29
  expect(spellcheck_report.errata.size).to eq 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: generic_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-18 00:00:00.000000000 Z
11
+ date: 2020-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: yamler
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - ">="
200
+ - !ruby/object:Gem::Version
201
+ version: '0'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
195
209
  description: Easy way to run generic tests for a website/api.
196
210
  email:
197
211
  - samuel.garratt@integrationqa.com