Skip to content

added ruby code in document #2306

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 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions examples/ruby/spec/interactions/cookies_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
it 'deletes a cookie by name' do
driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html'
driver.manage.add_cookie(name: 'test1', value: 'cookie1')
# Verify cookie exists
expect(driver.manage.cookie_named('test1')).not_to be_nil
# Delete cookie named
driver.manage.delete_cookie('test1')
# Verify cookie is deleted
Expand All @@ -52,8 +50,6 @@
# Add cookies into current browser context
driver.manage.add_cookie(name: 'test1', value: 'cookie1')
driver.manage.add_cookie(name: 'test2', value: 'cookie2')
# Verify cookies exist
expect(driver.manage.all_cookies.size).to eq(2)
# Delete All cookies
driver.manage.delete_all_cookies
# Verify all cookies are deleted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,8 @@ e.g. http://example.com/some404page)
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L32-L34" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'

# Adds the cookie into current browser context
driver.manage.add_cookie(name: "key", value: "value")
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L9-L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L18">}}
Expand Down Expand Up @@ -85,19 +75,8 @@ It returns the serialized cookie data matching with the cookie name among all as
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L40-L44" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "foo", value: "bar")

# Get cookie details with named cookie 'foo'
puts driver.manage.cookie_named('foo')
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L17-L21" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L35-L38">}}
Expand Down Expand Up @@ -138,20 +117,8 @@ If browser is no longer available it returns error.
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L51-L64" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# Get all available cookies
puts driver.manage.all_cookies
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L26-L31" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L49-L51">}}
Expand Down Expand Up @@ -193,20 +160,8 @@ It deletes the cookie data matching with the provided cookie name.
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L70-L73" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# delete a cookie with name 'test1'
driver.manage.delete_cookie('test1')
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L40-L43" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L61-L62">}}
Expand Down Expand Up @@ -251,20 +206,8 @@ It deletes all the cookies of the current browsing context.
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L92-L97" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# deletes all cookies
driver.manage.delete_all_cookies
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L49-L54" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L77-L78">}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,8 @@ Cookieの追加では、一連の定義済みのシリアル化可能なJSONオ
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L32-L34" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'

# Adds the cookie into current browser context
driver.manage.add_cookie(name: "key", value: "value")
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L9-L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L18">}}
Expand Down Expand Up @@ -81,19 +71,8 @@ fun main() {
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L40-L44" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "foo", value: "bar")

# Get cookie details with named cookie 'foo'
puts driver.manage.cookie_named('foo')
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L17-L21" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L35-L38">}}
Expand Down Expand Up @@ -133,20 +112,8 @@ fun main() {
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L51-L64" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# Get all available cookies
puts driver.manage.all_cookies
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L26-L31" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L49-L51">}}
Expand Down Expand Up @@ -187,20 +154,8 @@ fun main() {
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L70-L73" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# delete a cookie with name 'test1'
driver.manage.delete_cookie('test1')
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L40-L43" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L61-L62">}}
Expand Down Expand Up @@ -244,20 +199,8 @@ fun main() {
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L92-L97" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# deletes all cookies
driver.manage.delete_all_cookies
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L49-L54" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L77-L78">}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,8 @@ por exemplo http://example.com/some404page)
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L32-L34" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'

# Adds the cookie into current browser context
driver.manage.add_cookie(name: "key", value: "value")
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L9-L11" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L18">}}
Expand Down Expand Up @@ -83,19 +73,8 @@ Retorna os dados do cookie serializado correspondentes ao nome do cookie entre t
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L40-L44" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "foo", value: "bar")

# Get cookie details with named cookie 'foo'
puts driver.manage.cookie_named('foo')
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L17-L21" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L35-L38">}}
Expand Down Expand Up @@ -135,20 +114,8 @@ Se o navegador não estiver mais disponível, ele retornará um erro.
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L51-L64" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# Get all available cookies
puts driver.manage.all_cookies
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L26-L31" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L49-L51">}}
Expand Down Expand Up @@ -189,20 +156,8 @@ Exclui os dados do cookie que correspondem ao nome do cookie fornecido.
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L70-L73" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# delete a cookie with name 'test1'
driver.manage.delete_cookie('test1')
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L40-L43" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L61-L62">}}
Expand Down Expand Up @@ -246,20 +201,8 @@ Exclui todos os cookies do contexto de navegação atual.
{{< tab header="CSharp" text=true >}}
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L92-L97" >}}
{{< /tab >}}
{{< tab header="Ruby" >}}
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome

begin
driver.get 'https://www.example.com'
driver.manage.add_cookie(name: "test1", value: "cookie1")
driver.manage.add_cookie(name: "test2", value: "cookie2")

# deletes all cookies
driver.manage.delete_all_cookies
ensure
driver.quit
end
{{< tab header="Ruby" text=true >}}
{{< gh-codeblock path="examples/ruby/spec/interactions/cookies_spec.rb#L49-L54" >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L77-L78">}}
Expand Down
Loading
Loading