This repository has been archived by the owner on Jun 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
element_hidden_spec.rb
65 lines (52 loc) · 1.78 KB
/
element_hidden_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require File.expand_path("../spec_helper", __FILE__)
describe Watir::Locators::Element::Locator do
describe "Visible Elements" do
before do
browser.goto(WatirSpec.url_for("wait.html"))
end
context "when true" do
it "finds single element" do
element = browser.body.element(visible: true)
expect(element.id).to eq 'foo'
end
it "handles tag_name and index" do
element = browser.div(visible: true, index: 1)
expect(element.id).to eq 'buttons'
end
it "handles :tag_name and a single regexp attribute" do
element = browser.div(visible: true, id: /ons/)
expect(element.id).to eq 'buttons'
end
it "handles :xpath" do
element = browser.element(visible: true, xpath: './/div[@id="foo"]')
expect(element.id).to eq 'foo'
end
it "handles :css" do
element = browser.element(visible: true, css: 'div#foo')
expect(element.id).to eq 'foo'
end
end
context "when false" do
it "finds single element" do
element = browser.body.element(visible: false)
expect(element.id).to eq 'bar'
end
it "handles tag_name and index" do
element = browser.div(visible: false, index: 1)
expect(element.id).to eq 'also_hidden'
end
it "handles :tag_name and a single regexp attribute" do
element = browser.div(visible: false, id: /_/)
expect(element.id).to eq 'also_hidden'
end
it "handles :xpath" do
element = browser.element(visible: false, xpath: './/div[@id="bar"]')
expect(element.id).to eq 'bar'
end
it "handles :css" do
element = browser.element(visible: false, css: 'div#bar')
expect(element.id).to eq 'bar'
end
end
end
end