Sha256: d337387bfffa9b8f79fbe01cc530bd4a48edc77966241cd3bec5f8f7800a8f6d

Contents?: true

Size: 917 Bytes

Versions: 5

Compression:

Stored size: 917 Bytes

Contents

# frozen_string_literal: true

require 'eac_templates/core_ext'

module Aranha
  module Selenium
    class Session < ::SimpleDelegator
      class FormRequest
        acts_as_instance_method
        common_constructor :session, :path, :verb, :fields do
          self.fields = ::Aranha::Selenium::Session::FormRequest::Field.assert_all(fields)
        end

        def result
          session.execute_script(script.pretty_debug)
        end

        private

        # @return [String]
        def script
          template.child('form_request_function.js').apply(script_args: script_args)
        end

        # @return [String]
        def script_args
          ["'#{path}'", "'#{verb}'", script_fields_arg].join(', ')
        end

        # @return [String]
        def script_fields_arg
          "{#{fields.map(&:to_js_object).join(', ')}}"
        end

        require_sub __FILE__
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aranha-selenium-0.11.1 lib/aranha/selenium/session/form_request.rb
aranha-selenium-0.11.0 lib/aranha/selenium/session/form_request.rb
aranha-selenium-0.10.1 lib/aranha/selenium/session/form_request.rb
aranha-selenium-0.10.0 lib/aranha/selenium/session/form_request.rb
aranha-selenium-0.9.0 lib/aranha/selenium/session/form_request.rb