Module: TestSelector::TestHelper
- Defined in:
- lib/test_selector/test_helper.rb
Instance Method Summary collapse
Instance Method Details
#find_test_selector(html, selector) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/test_selector/test_helper.rb', line 17 def find_test_selector(html, selector) test_selector = selector.split(' ').first test_value = selector.split(' ').second doc = Nokogiri::HTML(html).css("[#{test_selector}]") if test_value doc.css("[#{test_value}]").to_s else doc.to_s end end |
#test_selector(path, name = nil, value = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/test_selector/test_helper.rb', line 5 def test_selector(path, name = nil, value = nil) underscore_path = path.gsub(%r{/|\.}, '_') if name && value "test-selector=_#{underscore_path}__#{name} test-value=#{value}" elsif name "test-selector=_#{underscore_path}__#{name}" else "test-selector=_#{underscore_path}" end end |