spec/watirspec/elements/element_spec.rb in watir-6.7.3 vs spec/watirspec/elements/element_spec.rb in watir-6.8.0

- old
+ new

@@ -97,11 +97,11 @@ it "finds several elements by xpath" do expect(browser.elements(xpath: "//a").length).to eq 1 end it "finds finds several elements by arbitrary attribute" do - expect(browser.elements(id: /^new_user/).length).to eq 32 + expect(browser.elements(id: /^new_user/).length).to eq 33 end it "finds an element from an element's subtree" do expect(browser.fieldset.element(id: "first_label")).to exist expect(browser.field_set.element(id: "first_label")).to exist @@ -364,22 +364,39 @@ it 'returns the element on which it was called' do expect(h2.flash).to eq h2 end end + describe '#text_content' do + it 'returns inner Text code of element' do + browser.goto WatirSpec.url_for('non_control_elements.html') + expect(browser.div(id: 'shown').text_content).to eq('Not shownNot hidden') + end + end + + describe '#inner_text' do + it 'returns inner HTML code of element' do + browser.goto WatirSpec.url_for('non_control_elements.html') + div = browser.div(id: 'shown') + expect(div.inner_text).to eq('Not hidden') + end + end + describe '#inner_html' do it 'returns inner HTML code of element' do - browser.goto WatirSpec.url_for('inner_outer.html') - div = browser.div(id: 'foo') - expect(div.inner_html).to eq('<a href="#">hello</a>') + browser.goto WatirSpec.url_for('non_control_elements.html') + div = browser.div(id: 'shown') + expected_text = "<div id=\"hidden\" style=\"display: none;\">Not shown</div><div>Not hidden</div>" + expect(div.inner_html).to eq expected_text end end describe '#outer_html' do it 'returns outer (inner + element itself) HTML code of element' do - browser.goto WatirSpec.url_for('inner_outer.html') - div = browser.div(id: 'foo') - expect(div.outer_html).to eq('<div id="foo"><a href="#">hello</a></div>') + browser.goto WatirSpec.url_for('non_control_elements.html') + div = browser.div(id: 'shown') + expected_text = "<div id=\"shown\"><div id=\"hidden\" style=\"display: none;\">Not shown</div><div>Not hidden</div></div>" + expect(div.outer_html).to eq expected_text end end not_compliant_on %i(remote firefox) do describe '#scroll_into_view' do