Skip to content

Commit c9a2ef6

Browse files
committed
Improve DevTools request interception test by loading different JS
1 parent 94c8c11 commit c9a2ef6

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
3+
<html lang="en">
4+
<head>
5+
<title>DevTools Request Interception Test</title>
6+
<script language="javascript" type="text/javascript" src="devtools_request_interception_test/one.js"></script>
7+
</head>
8+
9+
<body>
10+
<div id="result"></div>
11+
<button onClick="printScriptName()">
12+
Click me to print script name
13+
</button>
14+
</body>
15+
</html>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function printScriptName() {
2+
document.getElementById('result').innerHTML = 'one';
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function printScriptName() {
2+
document.getElementById('result').innerHTML = 'two';
3+
}

rb/spec/integration/selenium/webdriver/devtools_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,15 @@ module WebDriver
167167
it 'changes requests' do
168168
driver.intercept do |request, &continue|
169169
uri = URI(request.url)
170-
if uri.path.match?(%r{/html5/.*\.jpg})
171-
uri.path = '/beach.jpg'
170+
if uri.path.end_with?('one.js')
171+
uri.path = '/devtools_request_interception_test/two.js'
172172
request.url = uri.to_s
173173
end
174174
continue.call(request)
175175
end
176-
driver.navigate.to url_for('html5Page.html')
177-
expect(driver.find_elements(tag_name: 'img').map(&:size).uniq).to eq([Dimension.new(640, 480)])
176+
driver.navigate.to url_for('devToolsRequestInterceptionTest.html')
177+
driver.find_element(tag_name: 'button').click
178+
expect(driver.find_element(id: 'result').text).to eq('two')
178179
end
179180

180181
it 'continues responses' do

0 commit comments

Comments
 (0)