|
22 | 22 | not_compliant_on :driver => :remote, :browser => :marionette do |
23 | 23 | describe "Selenium::WebDriver::TargetLocator" do |
24 | 24 | after do |
25 | | - reset_driver! |
| 25 | + ensure_single_window |
26 | 26 | end |
27 | 27 |
|
28 | 28 | let(:wait) { Selenium::WebDriver::Wait.new } |
|
128 | 128 |
|
129 | 129 | # Marionette BUG: Automatically switches browsing context to new window when it opens. |
130 | 130 | not_compliant_on :driver => :marionette do |
131 | | - it "should close current window when more than two windows exist" do |
132 | | - driver.navigate.to url_for("xhtmlTest.html") |
133 | | - driver.find_element(:link, "Create a new anonymous window").click |
134 | | - driver.find_element(:link, "Open new window").click |
| 131 | + context "with more than two windows" do |
| 132 | + before(:each) do |
| 133 | + compliant_on :browser => :chrome do |
| 134 | + reset_driver! |
| 135 | + end |
| 136 | + end |
135 | 137 |
|
136 | | - wait.until { driver.window_handles.size == 3 } |
| 138 | + it "should close current window when more than two windows exist" do |
| 139 | + driver.navigate.to url_for("xhtmlTest.html") |
| 140 | + driver.find_element(:link, "Create a new anonymous window").click |
| 141 | + driver.find_element(:link, "Open new window").click |
137 | 142 |
|
138 | | - driver.switch_to.window(driver.window_handle) {driver.close} |
139 | | - expect(driver.window_handles.size).to eq 2 |
140 | | - end |
| 143 | + wait.until { driver.window_handles.size == 3 } |
141 | 144 |
|
142 | | - it "should close another window when more than two windows exist" do |
143 | | - driver.navigate.to url_for("xhtmlTest.html") |
144 | | - driver.find_element(:link, "Create a new anonymous window").click |
145 | | - driver.find_element(:link, "Open new window").click |
| 145 | + driver.switch_to.window(driver.window_handle) {driver.close} |
| 146 | + expect(driver.window_handles.size).to eq 2 |
| 147 | + end |
146 | 148 |
|
147 | | - wait.until { driver.window_handles.size == 3 } |
| 149 | + it "should close another window when more than two windows exist" do |
| 150 | + driver.navigate.to url_for("xhtmlTest.html") |
| 151 | + driver.find_element(:link, "Create a new anonymous window").click |
| 152 | + wait.until { driver.window_handles.size == 2 } |
| 153 | + driver.find_element(:link, "Open new window").click |
| 154 | + wait.until { driver.window_handles.size == 3 } |
148 | 155 |
|
149 | | - window_to_close = driver.window_handles.last |
| 156 | + window_to_close = driver.window_handles.last |
150 | 157 |
|
151 | | - driver.switch_to.window(window_to_close) { driver.close } |
152 | | - expect(driver.window_handles.size).to eq 2 |
153 | | - end |
| 158 | + driver.switch_to.window(window_to_close) { driver.close } |
| 159 | + expect(driver.window_handles.size).to eq 2 |
| 160 | + end |
154 | 161 |
|
155 | | - it "should iterate over open windows when current window is not closed" do |
156 | | - driver.navigate.to url_for("xhtmlTest.html") |
157 | | - driver.find_element(:link, "Create a new anonymous window").click |
158 | | - driver.find_element(:link, "Open new window").click |
| 162 | + it "should iterate over open windows when current window is not closed" do |
| 163 | + driver.navigate.to url_for("xhtmlTest.html") |
| 164 | + driver.find_element(:link, "Create a new anonymous window").click |
| 165 | + driver.find_element(:link, "Open new window").click |
| 166 | + |
| 167 | + wait.until { driver.window_handles.size == 3 } |
159 | 168 |
|
160 | | - wait.until { driver.window_handles.size == 3 } |
| 169 | + matching_window = driver.window_handles.find do |wh| |
| 170 | + driver.switch_to.window(wh) { driver.title == "We Arrive Here" } |
| 171 | + end |
161 | 172 |
|
162 | | - matching_window = driver.window_handles.find do |wh| |
163 | | - driver.switch_to.window(wh) { driver.title == "We Arrive Here" } |
| 173 | + driver.switch_to.window(matching_window) |
| 174 | + expect(driver.title).to eq("We Arrive Here") |
164 | 175 | end |
165 | 176 |
|
166 | | - driver.switch_to.window(matching_window) |
167 | | - expect(driver.title).to eq("We Arrive Here") |
168 | | - end |
| 177 | + it "should iterate over open windows when current window is closed" do |
| 178 | + driver.navigate.to url_for("xhtmlTest.html") |
| 179 | + driver.find_element(:link, "Create a new anonymous window").click |
| 180 | + driver.find_element(:link, "Open new window").click |
169 | 181 |
|
170 | | - it "should iterate over open windows when current window is closed" do |
171 | | - driver.navigate.to url_for("xhtmlTest.html") |
172 | | - driver.find_element(:link, "Create a new anonymous window").click |
173 | | - driver.find_element(:link, "Open new window").click |
| 182 | + wait.until { driver.window_handles.size == 3 } |
174 | 183 |
|
175 | | - wait.until { driver.window_handles.size == 3 } |
| 184 | + driver.close |
176 | 185 |
|
177 | | - driver.close |
| 186 | + matching_window = driver.window_handles.find do |wh| |
| 187 | + driver.switch_to.window(wh) { driver.title == "We Arrive Here" } |
| 188 | + end |
178 | 189 |
|
179 | | - matching_window = driver.window_handles.find do |wh| |
180 | | - driver.switch_to.window(wh) { driver.title == "We Arrive Here" } |
| 190 | + driver.switch_to.window(matching_window) |
| 191 | + expect(driver.title).to eq("We Arrive Here") |
181 | 192 | end |
182 | | - |
183 | | - driver.switch_to.window(matching_window) |
184 | | - expect(driver.title).to eq("We Arrive Here") |
185 | 193 | end |
186 | 194 | end |
187 | 195 |
|
|
0 commit comments