spec/unit/selector_builder/element_spec.rb in watir-6.19.1 vs spec/unit/selector_builder/element_spec.rb in watir-7.0.0.beta1
- old
+ new
@@ -93,19 +93,10 @@
built = {xpath: ".//*[contains(concat(' ', @class, ' '), ' user ')]"}
expect(selector_builder.build(selector)).to eq built
end
- it 'values with spaces' do
- selector = {class_name: 'multiple classes here'}
- built = {xpath: ".//*[contains(concat(' ', @class, ' '), ' multiple classes here ')]"}
-
- expect {
- expect(selector_builder.build(selector)).to eq built
- }.to have_deprecated_class_array
- end
-
it 'single String concatenates' do
selector = {class: 'user'}
built = {xpath: ".//*[contains(concat(' ', @class, ' '), ' user ')]"}
expect(selector_builder.build(selector)).to eq built
@@ -279,17 +270,15 @@
built = {xpath: ".//*[normalize-space()='Add user']"}
expect(selector_builder.build(selector)).to eq built
end
- it 'with caption attribute' do
- selector = {caption: 'Add user'}
- built = {xpath: ".//*[normalize-space()='Add user']"}
+ it 'Regexp uses contains normalize space' do
+ selector = {text: /Add/}
+ built = {xpath: ".//*[contains(normalize-space(), 'Add')]"}
- expect {
- expect(selector_builder.build(selector)).to eq built
- }.to have_deprecated_caption
+ expect(selector_builder.build(selector)).to eq built
end
it 'raises exception when text is not a String or Regexp' do
selector = {text: 7}
msg = /expected one of \[String, Regexp\], got 7:Integer/
@@ -344,11 +333,12 @@
expect(selector_builder.build(selector)).to eq built
end
it 'returns a label_element if complex' do
selector = {label: /Ca|rs/}
- built = {xpath: './/*', label_element: /Ca|rs/}
+ xpath = './/*[@id=//label[normalize-space()]/@for or parent::label[normalize-space()]]'
+ built = {xpath: xpath, label_element: /Ca|rs/}
expect(selector_builder.build(selector)).to eq built
end
it 'returns a visible_label_element if complex' do
@@ -622,16 +612,9 @@
end
it 'class with complicated Regexp' do
selector = {class: /he?r/}
built = {xpath: ".//*[contains(@class, 'h') and contains(@class, 'r')]", class: [/he?r/]}
-
- expect(selector_builder.build(selector)).to eq built
- end
-
- it 'text with any Regexp' do
- selector = {text: /Add/}
- built = {xpath: './/*', text: /Add/}
expect(selector_builder.build(selector)).to eq built
end
it 'visible' do