lib/true_automation/driver/capybara.rb in true_automation-0.4.0 vs lib/true_automation/driver/capybara.rb in true_automation-0.5.4
- old
+ new
@@ -5,22 +5,39 @@
alias_method :original_description, :description
def description(only_applied = false)
desc = original_description
matched_result = desc.match(/.*__taonly__(.+)__taonly__.*/)
if selector = matched_result && matched_result[1]
- desc = "TrueAutomation element #{selector} on the page"
+ desc = "Element was not found on the page. Element '#{selector}' with such locator is not on this page and could not be detected by TrueAutomation."
end
- matched_result_ta = desc.match(/.*(__ta__.+__ta__).*/)
- if selector = matched_result_ta && matched_result_ta[1]
- desc = desc.gsub(selector, '')
+ matched_result_ta = desc.match(/visible\s(.+)\s\"(.*)__ta__(.+)__ta__.*/)
+ if matched_result_ta && matched_result_ta[3]
+ desc = "Unable to locate element { using: '#{matched_result_ta[1]}', selector: '#{matched_result_ta[2]}' }"
end
desc
end
end
end
end
+module Capybara
+ module Node
+ module Finders
+ private
+ alias_method :original_synced_resolve, :synced_resolve
+ def synced_resolve(query)
+ begin
+ original_synced_resolve(query)
+ rescue Capybara::ElementNotFound => ex
+ raise Capybara::ElementNotFound, query.applied_description if query.locator.match(/.*__ta(only)*__(.+)__ta(only)*__.*/)
+ raise Capybara::ElementNotFound, ex
+ end
+ end
+ end
+ end
+end
+
module TrueAutomation
class RecordNotFound < StandardError; end
module Driver
class Capybara < Capybara::Selenium::Driver
@@ -28,10 +45,15 @@
options = fetch_options(options)
@port = options.delete(:port) || find_available_port('localhost')
@driver = options.delete(:driver)
@driver_version = options.delete(:driver_version)
+ if options && options[:ta_debug]
+ @ta_debug = ' --ta-debug'
+ options.delete(:ta_debug)
+ end
+
if options[:ta_service]
@ta_service = options.delete(:ta_service)
end
super(app, options)
@@ -59,9 +81,10 @@
def browser
unless @browser
@ta_client.start(port: @port,
remote: @remote,
+ ta_debug: @ta_debug,
driver: @driver,
ta_service_path: @ta_service&.executable_path,
driver_version: @driver_version)
@ta_client.wait_until_start