Sha256: 90bb3f49df5a3826af65168d3b15320111136d686114861fde8d633935cacbda

Contents?: true

Size: 904 Bytes

Versions: 1

Compression:

Stored size: 904 Bytes

Contents

module Webdriver
  class Session
    attr_reader :id

    def initialize(json, connection)
      @id = json.dig "id"
      @connection = Webdriver::PrefixConnection.new "session/#{@id}", connection
    end

    def delete!
      @connection.delete
    end

    def windows
      value = @connection.get "window/handles"
      value.map { |id| Webdriver::Window.new id, @connection }
    end

    def url! url
      @connection.post "url", {}, {
        url: url
      }
    end

    def url
      @connection.get "url"
    end

    def back!
      @connection.post "back"
    end

    def forward!
      @connection.post "forward"
    end

    def refresh!
      @connection.post "refresh"
    end

    def title
      @connection.get "title"
    end

    def execute_sync! script, args=[]
      @connection.post "execute/sync", {}, {
        script: script,
        args: args
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webdriver-0.3.0 lib/webdriver/session.rb