Skip to content

Commit 067a295

Browse files
committed
rb: fix timing issues in specs
1 parent c321805 commit 067a295

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

rb/spec/integration/selenium/webdriver/target_locator_spec.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
}.should raise_error(RuntimeError, "foo")
9191

9292
driver.title.should == "XHTML Test Page"
93-
9493
end
9594

9695
it "should switch to a window" do
@@ -100,8 +99,7 @@
10099
wait.until { driver.title == "XHTML Test Page" }
101100

102101
driver.switch_to.window("result")
103-
wait.until { driver.title == "We Arrive Here" }
104-
102+
driver.title.should == "We Arrive Here"
105103
end
106104

107105
it "should use the original window if the block closes the popup" do
@@ -124,7 +122,7 @@
124122
driver.find_element(:link, "Create a new anonymous window").click
125123
driver.find_element(:link, "Open new window").click
126124

127-
expect(driver.window_handles.size).to eq 3
125+
wait.until { driver.window_handles.size == 3 }
128126

129127
driver.switch_to.window(driver.window_handle) {driver.close}
130128
expect(driver.window_handles.size).to eq 2
@@ -135,11 +133,11 @@
135133
driver.find_element(:link, "Create a new anonymous window").click
136134
driver.find_element(:link, "Open new window").click
137135

138-
expect(driver.window_handles.size).to eq 3
136+
wait.until { driver.window_handles.size == 3 }
139137

140138
window_to_close = driver.window_handles.last
141139

142-
driver.switch_to.window(window_to_close) {driver.close}
140+
driver.switch_to.window(window_to_close) { driver.close }
143141
expect(driver.window_handles.size).to eq 2
144142
end
145143

@@ -175,6 +173,8 @@
175173
driver.navigate.to url_for("xhtmlTest.html")
176174
driver.find_element(:link, "Open new window").click
177175

176+
wait.until { driver.window_handles.size == 2 }
177+
178178
driver.switch_to.window("result")
179179
wait.until { driver.title == "We Arrive Here" }
180180

@@ -205,7 +205,8 @@
205205
driver.navigate.to url_for("alerts.html")
206206
driver.find_element(:id => "alert").click
207207

208-
driver.switch_to.alert.accept
208+
alert = wait_for_alert
209+
alert.accept
209210

210211
driver.title.should == "Testing Alerts"
211212
end

0 commit comments

Comments
 (0)