Class: Xing::Snapshot::LocalSiteSnapshot
- Inherits:
-
SiteSnapshot
- Object
- SiteSnapshot
- Xing::Snapshot::LocalSiteSnapshot
- Includes:
- Writer
- Defined in:
- lib/xing/snapshot/local_site_snapshot.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#wait ⇒ Object
Returns the value of attribute wait.
Attributes inherited from SiteSnapshot
Instance Method Summary collapse
- #fetch(url, path) ⇒ Object
-
#initialize(url) ⇒ LocalSiteSnapshot
constructor
A new instance of LocalSiteSnapshot.
- #setup ⇒ Object
- #teardown ⇒ Object
Methods included from Writer
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
#driver ⇒ Object
Returns the value of attribute driver.
18 19 20 |
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 18 def driver @driver end |
#wait ⇒ Object
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 |
#setup ⇒ Object
15 16 17 |
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 15 def setup @driver = Selenium::WebDriver.for :chrome end |
#teardown ⇒ Object
20 21 22 |
# File 'lib/xing/snapshot/local_site_snapshot.rb', line 20 def teardown @driver.close end |