Skip to content

Commit 3ae348f

Browse files
Merge branch 'trunk' into dotnet-nullable
2 parents 9a1f270 + 3a6f47b commit 3ae348f

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

rb/lib/selenium/webdriver/bidi/browsing_context.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ def create(type: nil, context_id: nil)
9494
result = @bidi.send_cmd('browsingContext.create', type: type.to_s, referenceContext: context_id)
9595
result['context']
9696
end
97+
98+
def set_viewport(context_id: nil, width: nil, height: nil, device_pixel_ratio: nil)
99+
context_id ||= @bridge.window_handle
100+
params = {context: context_id, viewport: {width:, height:}, device_pixel_ratio:}
101+
@bidi.send_cmd('browsingContext.setViewport', **params)
102+
end
97103
end
98104
end # BiDi
99105
end # WebDriver

rb/sig/lib/selenium/webdriver/bidi/browsing_context.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ module Selenium
1010

1111
def navigate: (String url, String? context_id) -> void
1212

13+
def set_viewport: (String context_id, Integer width, Integer height, Float device_pixel_ratio) -> Hash[nil, nil]
14+
1315
def traverse_history: (Integer delta, String? context_id) -> void
1416

1517
def reload: (String? context_id, ?ignore_cache: bool) -> void

rb/spec/integration/selenium/webdriver/bidi/browsing_context_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ class BiDi
7373
expect(handles).to include(window1)
7474
expect(handles).not_to include(window2)
7575
end
76+
77+
it 'sets the viewport' do
78+
reset_driver!(web_socket_url: true) do |driver|
79+
browsing_context = described_class.new(driver)
80+
browsing_context.set_viewport(width: 800, height: 600, device_pixel_ratio: 2.0)
81+
expect(driver.execute_script('return [window.innerWidth, window.innerHeight]')).to eq([800, 600])
82+
expect(driver.execute_script('return window.devicePixelRatio')).to eq(2.0)
83+
end
84+
end
7685
end
7786
end # BiDi
7887
end # WebDriver

rust/src/metadata.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use std::fs::File;
2323
use std::path::{Path, PathBuf};
2424
use std::time::{SystemTime, UNIX_EPOCH};
2525

26-
const METADATA_FILE_OLD: &str = "selenium-manager.json";
2726
const METADATA_FILE: &str = "se-metadata.json";
2827

2928
#[derive(Serialize, Deserialize)]
@@ -61,10 +60,6 @@ pub struct Metadata {
6160
}
6261

6362
fn get_metadata_path(cache_path: PathBuf) -> PathBuf {
64-
let old_metadata = cache_path.join(METADATA_FILE_OLD);
65-
if old_metadata.exists() {
66-
fs::remove_file(old_metadata).unwrap_or_default();
67-
}
6863
cache_path.join(METADATA_FILE)
6964
}
7065

0 commit comments

Comments
 (0)