Class: Chemlab::Runtime::Browser::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/chemlab/runtime/browser.rb

Overview

An individual session

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, browser) ⇒ Session

Returns a new instance of Session.



31
32
33
34
35
# File 'lib/chemlab/runtime/browser.rb', line 31

def initialize(url, browser)
  @engine = Watir::Browser.new(*browser)

  @engine.goto(Chemlab.configuration.base_url)
end

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



29
30
31
# File 'lib/chemlab/runtime/browser.rb', line 29

def engine
  @engine
end

Instance Method Details

#current_urlObject



37
38
39
# File 'lib/chemlab/runtime/browser.rb', line 37

def current_url
  engine.url
end

#quitObject



49
50
51
# File 'lib/chemlab/runtime/browser.rb', line 49

def quit
  engine.close
end

#refreshObject



41
42
43
# File 'lib/chemlab/runtime/browser.rb', line 41

def refresh
  engine.refresh
end

#save_screenshot(file_name) ⇒ Object



53
54
55
# File 'lib/chemlab/runtime/browser.rb', line 53

def save_screenshot(file_name)
  engine.screenshot.save(file_name)
end

#textObject



45
46
47
# File 'lib/chemlab/runtime/browser.rb', line 45

def text
  engine.text
end

#wait_until(timeout, message = nil, &block) ⇒ Object



57
58
59
# File 'lib/chemlab/runtime/browser.rb', line 57

def wait_until(timeout, message = nil, &block)
  engine.wait_until(timeout: timeout, message: message, &block)
end

#wait_while(timeout, message = nil, &block) ⇒ Object



61
62
63
# File 'lib/chemlab/runtime/browser.rb', line 61

def wait_while(timeout, message = nil, &block)
  engine.wait_while(timeout: timeout, message: message, &block)
end