Class: Xing::Snapshot::LocalSiteSnapshot

Inherits:
SiteSnapshot show all
Includes:
Writer
Defined in:
lib/xing/snapshot/local_site_snapshot.rb

Instance Attribute Summary collapse

Attributes inherited from SiteSnapshot

#url

Instance Method Summary collapse

Methods included from Writer

#write

Methods inherited from SiteSnapshot

create!, #create!, #generate_snapshot

Constructor Details

#initialize(url) ⇒ LocalSiteSnapshot

Returns a new instance of LocalSiteSnapshot.



10
11
12
13
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 10

def initialize(url)
  super(url)
  @wait = Selenium::WebDriver::Wait.new
end

Instance Attribute Details

#driverObject

Returns the value of attribute driver.



18
19
20
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 18

def driver
  @driver
end

#waitObject

Returns the value of attribute wait.



18
19
20
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 18

def wait
  @wait
end

Instance Method Details

#fetch(url, path) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 24

def fetch(url, path)
  @driver.navigate.to(url+path)
  # better way to wait till javascript complete?
  @wait.until do
    @driver.execute_script("return window.frontendContentLoaded == true;")
  end
  element = @driver.find_element(:tag_name, "html")
  html = element.attribute("outerHTML")
  write(path, html)
end

#setupObject



15
16
17
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 15

def setup
  @driver = Selenium::WebDriver.for :chrome
end

#teardownObject



20
21
22
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 20

def teardown
  @driver.close
end