Skip to content

Commit

Permalink
Expand options documentation test and examples for Ruby (#1679)[deplo…
Browse files Browse the repository at this point in the history
…y site]

* Expand options documentation test and examples

* Update timeouts examples

* Update all navigations

* Update options after updating the tests

* Update options after updating the tests

* Fix documentation bug

---------

Co-authored-by: aguspe <[email protected]>
  • Loading branch information
aguspe and aguspe authored Apr 27, 2024
1 parent 9b3fc36 commit 568da88
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 86 deletions.
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

0 comments on commit 568da88

Please sign in to comment.