Class: TrueAutomation::Driver::Capybara
- Inherits:
-
Capybara::Selenium::Driver
- Object
- Capybara::Selenium::Driver
- TrueAutomation::Driver::Capybara
- Defined in:
- lib/true_automation/driver/capybara.rb
Instance Method Summary collapse
- #browser ⇒ Object
-
#initialize(app, **options) ⇒ Capybara
constructor
A new instance of Capybara.
- #quit ⇒ Object
- #specialize_driver(*args) ⇒ Object
Constructor Details
#initialize(app, **options) ⇒ Capybara
Returns a new instance of Capybara.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/true_automation/driver/capybara.rb', line 27 def initialize(app, **) @port = .delete(:port) || 9515 @driver = .delete(:driver) @driver_version = .delete(:driver_version) super(app, ) @ta_client = TrueAutomation::Client.new @remote = '' ||= {} ta_url = [:ta_url] || "http://localhost:#{@port}/" capabilities = [:desired_capabilities] || {} if and [:browser] == :remote raise 'Remote driver URL is not specified' unless [:url] capabilities[:taRemoteUrl] = [:url] @remote = ' --remote' else capabilities[:browser] = [:browser] || :chrome end .merge!(browser: :remote, url: ta_url, desired_capabilities: capabilities) end |
Instance Method Details
#browser ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/true_automation/driver/capybara.rb', line 55 def browser unless @browser @ta_client.start(port: @port, remote: @remote, driver: @driver, driver_version: @driver_version) @ta_client.wait_until_start at_exit do @ta_client.stop end super end @browser end |
#quit ⇒ Object
73 74 75 76 |
# File 'lib/true_automation/driver/capybara.rb', line 73 def quit super @ta_client.stop end |
#specialize_driver(*args) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/true_automation/driver/capybara.rb', line 78 def specialize_driver(*args) if ::::Selenium::Driver.respond_to?(:register_specialization) browser_type = browser.browser # Original method uses self.class, and all classes use Capybara::Selenium::Driver. # Thereby no specializations in the list for TA driver class and error occured. ::::Selenium::Driver.specializations.select { |k, _v| k === browser_type }.each_value do |specialization| # rubocop:disable Style/CaseEquality extend specialization end else super end end |