diff options
author | Mark Lapierre <mlapierre@gitlab.com> | 2019-06-12 05:08:32 +0300 |
---|---|---|
committer | Mark Lapierre <mlapierre@gitlab.com> | 2019-06-12 05:08:32 +0300 |
commit | 14d19dfab264847477577002940d0c07a96502db (patch) | |
tree | 30a930f5b85519845c91de71a9d3292cc4d49659 | |
parent | c6152f3d28fd609600eeea10fbd38202b33af2d9 (diff) |
Validate page after visiting it
When `visit` is called with a block it now visits the page
before validating it, and then executes the block
-rw-r--r-- | qa/qa/runtime/address.rb | 2 | ||||
-rw-r--r-- | qa/qa/runtime/browser.rb | 19 |
2 files changed, 13 insertions, 8 deletions
diff --git a/qa/qa/runtime/address.rb b/qa/qa/runtime/address.rb index 98d042fb43a..c622051bb6d 100644 --- a/qa/qa/runtime/address.rb +++ b/qa/qa/runtime/address.rb @@ -5,7 +5,7 @@ module QA class Address attr_reader :address - def initialize(instance, page = nil) + def initialize(instance, page) @instance = instance @address = host + (page.is_a?(String) ? page : page&.path) end diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb index 3bf4b3bbbfb..ed0779b93cc 100644 --- a/qa/qa/runtime/browser.rb +++ b/qa/qa/runtime/browser.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'rspec/core' +require 'rspec/expectations' require 'capybara/rspec' require 'capybara-screenshot/rspec' require 'selenium-webdriver' @@ -27,13 +28,12 @@ module QA # In case of an address that is a symbol we will try to guess address # based on `Runtime::Scenario#something_address`. # - def visit(address, page = nil, &block) - Browser::Session.new(address, page).perform(&block) + def visit(address, page_class, &block) + Browser::Session.new(address, page_class).perform(&block) end - def self.visit(address, page = nil, &block) - new.visit(address, page, &block) - page.validate_elements_present! + def self.visit(address, page_class, &block) + new.visit(address, page_class, &block) end def self.configure! @@ -128,8 +128,11 @@ module QA class Session include Capybara::DSL - def initialize(instance, page = nil) - @session_address = Runtime::Address.new(instance, page) + attr_reader :page_class + + def initialize(instance, page_class) + @session_address = Runtime::Address.new(instance, page_class) + @page_class = page_class end def url @@ -139,6 +142,8 @@ module QA def perform(&block) visit(url) + page_class.validate_elements_present! + if QA::Runtime::Env.qa_cookies browser = Capybara.current_session.driver.browser QA::Runtime::Env.qa_cookies.each do |cookie| |