Skip to content

Expand options documentation test and examples for Ruby #1679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
49af31b
Expand options documentation test and examples
aguspe Apr 19, 2024
711c3c2
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 19, 2024
f8f7c1d
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 21, 2024
65d3aeb
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 21, 2024
fd90d6e
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 22, 2024
11eb35e
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 23, 2024
c591765
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 23, 2024
0c9738a
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 24, 2024
919d47c
Update timeouts examples
aguspe Apr 24, 2024
846a11a
Merge remote-tracking branch 'origin/expand_options_example_page' int…
aguspe Apr 24, 2024
af36eaa
Update all navigations
aguspe Apr 24, 2024
a7a8b92
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 24, 2024
4ce8459
Update options after updating the tests
aguspe Apr 25, 2024
ac5be92
Merge remote-tracking branch 'origin/expand_options_example_page' int…
aguspe Apr 25, 2024
b7b76f7
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 25, 2024
8277f06
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 25, 2024
5bc74d7
Update options after updating the tests
aguspe Apr 25, 2024
165749a
Fix documentation bug
aguspe Apr 25, 2024
fe98ff5
Merge remote-tracking branch 'origin/expand_options_example_page' int…
aguspe Apr 25, 2024
f517ba2
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 25, 2024
a5a3a58
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 26, 2024
e49c40d
Merge branch 'trunk' into expand_options_example_page
aguspe Apr 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 77 additions & 4 deletions examples/ruby/spec/drivers/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
RSpec.describe 'Chrome' do
describe 'Driver Options' do
let(:chrome_location) { driver_finder && ENV.fetch('CHROME_BIN', nil) }
let(:url) { 'https://www.selenium.dev/selenium/web/' }

it 'page load strategy normal' do
options = Selenium::WebDriver::Options.chrome
options.page_load_strategy = :normal

driver = Selenium::WebDriver.for :chrome, options: options
driver.get('https://www.google.com')
driver.get(url)
driver.quit
end

Expand All @@ -20,7 +21,7 @@
options.page_load_strategy = :eager

driver = Selenium::WebDriver.for :chrome, options: options
driver.get('https://www.google.com')
driver.get(url)
driver.quit
end

Expand All @@ -29,7 +30,7 @@
options.page_load_strategy = :none

driver = Selenium::WebDriver.for :chrome, options: options
driver.get('https://www.google.com')
driver.get(url)
driver.quit
end

Expand All @@ -42,7 +43,79 @@
cloud_options[:name] = my_test_name
options.add_option('cloud:options', cloud_options)
driver = Selenium::WebDriver.for :remote, capabilities: options
driver.get('https://www.google.com')
driver.get(url)
driver.quit
end

it 'accepts untrusted certificates' do
options = Selenium::WebDriver::Options.chrome
options.accept_insecure_certs = true

driver = Selenium::WebDriver.for :chrome, options: options
driver.get(url)
driver.quit
end

it 'sets unhandled prompt behavior' do
options = Selenium::WebDriver::Options.chrome
options.unhandled_prompt_behavior = :accept

driver = Selenium::WebDriver.for :chrome, options: options
driver.get(url)
driver.quit
end

it 'sets window rect' do
options = Selenium::WebDriver::Options.firefox
options.set_window_rect = true

driver = Selenium::WebDriver.for :firefox, options: options
driver.get(url)
driver.quit
end

it 'sets strict file interactability' do
options = Selenium::WebDriver::Options.chrome
options.strict_file_interactability = true

driver = Selenium::WebDriver.for :chrome, options: options
driver.get(url)
driver.quit
end

it 'sets the proxy' do
options = Selenium::WebDriver::Options.chrome
options.proxy = Selenium::WebDriver::Proxy.new(http: 'myproxy.com:8080')

driver = Selenium::WebDriver.for :chrome, options: options
driver.get(url)
driver.quit
end

it 'sets the implicit timeout' do
options = Selenium::WebDriver::Options.chrome
options.timeouts = {implicit: 1}

driver = Selenium::WebDriver.for :chrome, options: options
driver.get(url)
driver.quit
end

it 'sets the page load timeout' do
options = Selenium::WebDriver::Options.chrome
options.timeouts = {page_load: 400_000}

driver = Selenium::WebDriver.for :chrome, options: options
driver.get(url)
driver.quit
end

it 'sets the script timeout' do
options = Selenium::WebDriver::Options.chrome
options.timeouts = {script: 40_000}

driver = Selenium::WebDriver.for :chrome, options: options
driver.get(url)
driver.quit
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Browser name is set by default when using an Options class instance.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L10" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -67,7 +67,7 @@ it will be automatically downloaded by [Selenium Manager]({{< ref "../../seleniu
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/service_spec.rb#L35" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/service_spec.rb#L40" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -139,7 +139,7 @@ namespace pageLoadStrategy {
}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L10-L11">}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L11-L12">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/capabilities/pageLoading.spec.js#L28-L34">}}
Expand Down Expand Up @@ -196,7 +196,7 @@ namespace pageLoadStrategy {
}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L19-L20">}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L20-L21">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/capabilities/pageLoading.spec.js#L8-L14">}}
Expand Down Expand Up @@ -252,7 +252,7 @@ namespace pageLoadStrategy {
}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L28-L29">}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L29-L30">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/capabilities/pageLoading.spec.js#L18-L24">}}
Expand Down Expand Up @@ -296,7 +296,7 @@ setting `platformName` sets the OS at the remote-end.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L37-L38" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L38-L39" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -334,7 +334,7 @@ effect for the entire session.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L51-L52" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -369,7 +369,7 @@ is imposed when a new session is created by WebDriver.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L114-L115" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -398,7 +398,7 @@ _TimeoutException_.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L105-L106" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -425,7 +425,7 @@ is imposed when a new session is created by WebDriver.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L96-L97" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -463,7 +463,7 @@ user prompt encounters at the remote-end. This is defined by
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L60-L61" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -488,7 +488,7 @@ Indicates whether the remote end supports all of the [resizing and repositioning
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L69-L70" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -516,7 +516,7 @@ when using _Element Send Keys_ with hidden file upload controls.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L78-L79" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -603,12 +603,7 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/");
}
{{< /tab >}}
{{< tab header="Ruby" >}}

proxy = Selenium::WebDriver::Proxy.new(http: '<HOST:PORT>')
cap = Selenium::WebDriver::Remote::Capabilities.chrome(proxy: proxy)

driver = Selenium::WebDriver.for(:chrome, capabilities: cap)
driver.get('http://google.com')
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L87-L88" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let webdriver = require('selenium-webdriver');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Browser name is set by default when using an Options class instance.
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L10" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -68,7 +68,7 @@ it will be automatically downloaded by [Selenium Manager]({{< ref "../../seleniu
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/service_spec.rb#L35" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/service_spec.rb#L40" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -137,7 +137,7 @@ namespace pageLoadStrategy {
}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L10-L11">}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L11-L12">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/capabilities/pageLoading.spec.js#L28-L34">}}
Expand Down Expand Up @@ -193,7 +193,7 @@ namespace pageLoadStrategy {
}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L19-L20">}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L20-L21">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/capabilities/pageLoading.spec.js#L8-L14">}}
Expand Down Expand Up @@ -248,7 +248,7 @@ namespace pageLoadStrategy {
}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L28-L29">}}
{{< gh-codeblock path="/examples/ruby/spec/drivers/options_spec.rb#L29-L30">}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/capabilities/pageLoading.spec.js#L18-L24">}}
Expand Down Expand Up @@ -290,7 +290,7 @@ fun main() {
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L37-L38" >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L38-L39" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -322,7 +322,7 @@ fun main() {
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L51-L52" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -354,7 +354,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L114-L115" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -380,7 +380,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L105-L106" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -405,7 +405,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L96-L97" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -442,7 +442,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L60-L61" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -468,7 +468,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L69-L70" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand All @@ -495,7 +495,7 @@ WebDriverの `セッション` には特定の `セッションタイムアウ
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
{{< badge-code >}}
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L78-L79" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
{{< badge-code >}}
Expand Down Expand Up @@ -577,13 +577,7 @@ driver.Navigate().GoToUrl("https://www.selenium.dev/");
}
{{< /tab >}}
{{< tab header="Ruby" >}}
# this code was written with Selenium 4

proxy = Selenium::WebDriver::Proxy.new(http: '<HOST:PORT>')
cap = Selenium::WebDriver::Remote::Capabilities.chrome(proxy: proxy)

driver = Selenium::WebDriver.for(:chrome, capabilities: cap)
driver.get('http://google.com')
{{< gh-codeblock path="examples/ruby/spec/drivers/options_spec.rb#L87-L88" >}}
{{< /tab >}}
{{< tab header="JavaScript" >}}
let webdriver = require('selenium-webdriver');
Expand Down
Loading
Loading