Class: Metallize::Page::Link
- Inherits:
-
Object
- Object
- Metallize::Page::Link
- Defined in:
- lib/metallize/page/link.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
Instance Method Summary collapse
- #click ⇒ Object
- #href ⇒ Object
-
#initialize(driver, link) ⇒ Link
constructor
A new instance of Link.
-
#pretty_print(q) ⇒ Object
:nodoc:.
- #text ⇒ Object
Constructor Details
#initialize(driver, link) ⇒ Link
Returns a new instance of Link.
5 6 7 8 |
# File 'lib/metallize/page/link.rb', line 5 def initialize(driver, link) @driver = driver @link = link end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
3 4 5 |
# File 'lib/metallize/page/link.rb', line 3 def driver @driver end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
3 4 5 |
# File 'lib/metallize/page/link.rb', line 3 def link @link end |
Instance Method Details
#click ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/metallize/page/link.rb', line 19 def click link.click # 1. Wait for the Page State to Return wait = Selenium::WebDriver::Wait.new(:timeout => 10) wait.until { driver.execute_script("return document.readyState;") == "complete" } # 2. Return new Page Metallize::Page.new(driver) end |
#href ⇒ Object
14 15 16 17 |
# File 'lib/metallize/page/link.rb', line 14 def href link_attribute = link.attribute('href') URI(link_attribute).path end |
#pretty_print(q) ⇒ Object
:nodoc:
32 33 34 35 36 37 |
# File 'lib/metallize/page/link.rb', line 32 def pretty_print(q) # :nodoc: q.object_group(self) { q.breakable; q.pp text q.breakable; q.pp href } end |
#text ⇒ Object
10 11 12 |
# File 'lib/metallize/page/link.rb', line 10 def text link.text end |