Class: Webdrone::Browser

Inherits:
Object
  • Object
show all
Defined in:
lib/webdrone/clic.rb,
lib/webdrone/conf.rb,
lib/webdrone/ctxt.rb,
lib/webdrone/exec.rb,
lib/webdrone/find.rb,
lib/webdrone/form.rb,
lib/webdrone/mark.rb,
lib/webdrone/open.rb,
lib/webdrone/shot.rb,
lib/webdrone/text.rb,
lib/webdrone/vrfy.rb,
lib/webdrone/wait.rb,
lib/webdrone/xlsx.rb,
lib/webdrone/browser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(browser: 'chrome', create_outdir: false, outdir: nil) ⇒ Browser

Returns a new instance of Browser.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/webdrone/browser.rb', line 5

def initialize(browser: 'chrome', create_outdir: false, outdir: nil)
  if create_outdir or outdir
    outdir ||= "webdrone_output/#{Time.new.strftime('%Y%m%d_%H%M')}"
    self.conf.outdir = outdir
  end
  if outdir != nil and browser.to_sym == :chrome
    prefs = { download: { prompt_for_download: false, default_directory: outdir } }
    @driver = Selenium::WebDriver.for browser.to_sym, prefs: prefs
  elsif outdir != nil and browser.to_sym == :firefox
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile['startup.homepage_welcome_url.additional'] = 'about:blank'
    profile['browser.download.dir'] = outdir
    profile['browser.download.folderList'] = 2
    profile['browser.download.manager.showWhenStarting'] = false
    profile['browser.helperApps.neverAsk.saveToDisk'] = "images/jpeg, application/pdf, application/octet-stream"
    @driver = Selenium::WebDriver.for browser.to_sym, profile: profile
  else
    @driver = Selenium::WebDriver.for browser.to_sym
  end
end

Instance Attribute Details

#driverObject

Returns the value of attribute driver.



3
4
5
# File 'lib/webdrone/browser.rb', line 3

def driver
  @driver
end

Instance Method Details

#clicObject



3
4
5
# File 'lib/webdrone/clic.rb', line 3

def clic
  @clic ||= Clic.new self
end

#confObject



3
4
5
# File 'lib/webdrone/conf.rb', line 3

def conf
  @conf ||= Conf.new self
end

#ctxtObject



3
4
5
# File 'lib/webdrone/ctxt.rb', line 3

def ctxt
  @ctxt ||= Ctxt.new self
end

#execObject



3
4
5
# File 'lib/webdrone/exec.rb', line 3

def exec
  @exec ||= Exec.new self
end

#findObject



3
4
5
# File 'lib/webdrone/find.rb', line 3

def find
  @find ||= Find.new self
end

#formObject



3
4
5
# File 'lib/webdrone/form.rb', line 3

def form
  @form ||= Form.new self
end

#markObject



3
4
5
# File 'lib/webdrone/mark.rb', line 3

def mark
  @mark ||= Mark.new self
end

#openObject



3
4
5
# File 'lib/webdrone/open.rb', line 3

def open
  @open ||= Open.new self
end

#quitObject



26
27
28
# File 'lib/webdrone/browser.rb', line 26

def quit
  @driver.quit
end

#shotObject



3
4
5
# File 'lib/webdrone/shot.rb', line 3

def shot
  @shot ||= Shot.new self
end

#textObject



3
4
5
# File 'lib/webdrone/text.rb', line 3

def text
  @text ||= Text.new self
end

#vrfyObject



3
4
5
# File 'lib/webdrone/vrfy.rb', line 3

def vrfy
  @vrfy ||= Vrfy.new self
end

#waitObject



3
4
5
# File 'lib/webdrone/wait.rb', line 3

def wait
  @wait ||= Wait.new self
end

#xlsxObject



3
4
5
# File 'lib/webdrone/xlsx.rb', line 3

def xlsx
  @xlsx ||= Xlsx.new self
end