Class: Watir::Browser
- Inherits:
-
Object
- Object
- Watir::Browser
- Defined in:
- lib/unused_css/watir.rb
Instance Attribute Summary collapse
-
#stylesheets ⇒ Object
Returns the value of attribute stylesheets.
Instance Method Summary collapse
- #check_for_unused_styles! ⇒ Object
- #goto(*args) ⇒ Object
-
#initialize(*args) ⇒ Browser
constructor
A new instance of Browser.
- #original_goto ⇒ Object
- #original_initialize ⇒ Object
- #stylesheets_on_page ⇒ Object
Constructor Details
#initialize(*args) ⇒ Browser
Returns a new instance of Browser.
9 10 11 12 |
# File 'lib/unused_css/watir.rb', line 9 def initialize(*args) @stylesheets = Stylesheets.new original_initialize(*args) end |
Instance Attribute Details
#stylesheets ⇒ Object
Returns the value of attribute stylesheets.
6 7 8 |
# File 'lib/unused_css/watir.rb', line 6 def stylesheets @stylesheets end |
Instance Method Details
#check_for_unused_styles! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/unused_css/watir.rb', line 25 def check_for_unused_styles! @stylesheets.each do |stylesheet| stylesheet.unused_styles.delete_if { |style| self.element(css: style).exist? } stylesheet.remove_pseudo_styles! end end |
#goto(*args) ⇒ Object
15 16 17 18 19 |
# File 'lib/unused_css/watir.rb', line 15 def goto(*args) original_goto(*args) @stylesheets.add stylesheets_on_page check_for_unused_styles! end |
#original_goto ⇒ Object
14 |
# File 'lib/unused_css/watir.rb', line 14 alias_method :original_goto, :goto |
#original_initialize ⇒ Object
8 |
# File 'lib/unused_css/watir.rb', line 8 alias_method :original_initialize, :initialize |
#stylesheets_on_page ⇒ Object
21 22 23 |
# File 'lib/unused_css/watir.rb', line 21 def stylesheets_on_page elements(tag_name: 'link').map { |stylesheet| stylesheet.attribute_value('href') } end |