diff --git a/examples/ruby/spec/interactions/cookies_spec.rb b/examples/ruby/spec/interactions/cookies_spec.rb index fe5b3dfc4235..f36fd21a55a9 100644 --- a/examples/ruby/spec/interactions/cookies_spec.rb +++ b/examples/ruby/spec/interactions/cookies_spec.rb @@ -3,5 +3,81 @@ require 'spec_helper' RSpec.describe 'Cookies' do - let(:driver) { start_session } + before(:each) do + @driver = Selenium::WebDriver.for :chrome + end + + after(:each) do + @driver.quit + end + + it 'adds a cookie' do + @driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html' + @driver.manage.add_cookie(name: 'key', value: 'value') + end + + it 'gets a named cookie' do + @driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html' + @driver.manage.add_cookie(name: 'foo', value: 'bar') + cookie = @driver.manage.cookie_named('foo') + expect(cookie[:value]).to eq('bar') + end + + it 'gets all cookies' do + @driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html' + @driver.manage.add_cookie(name: 'test1', value: 'cookie1') + @driver.manage.add_cookie(name: 'test2', value: 'cookie2') + + cookies = @driver.manage.all_cookies + test1 = cookies.find { |c| c[:name] == 'test1' } + test2 = cookies.find { |c| c[:name] == 'test2' } + + expect(test1[:value]).to eq('cookie1') + expect(test2[:value]).to eq('cookie2') + end + + 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') + @driver.manage.delete_cookie('test1') + expect(@driver.manage.cookie_named('test1')).to be_nil + end + + it 'deletes a cookie using cookie object' do + @driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html' + cookie = { name: 'test2', value: 'cookie2' } + @driver.manage.add_cookie(cookie) + @driver.manage.delete_cookie('test2') + expect(@driver.manage.cookie_named('test2')).to be_nil + end + + it 'deletes all cookies' do + @driver.navigate.to 'https://www.selenium.dev/selenium/web/blank.html' + @driver.manage.add_cookie(name: 'test1', value: 'cookie1') + @driver.manage.add_cookie(name: 'test2', value: 'cookie2') + @driver.manage.delete_all_cookies + expect(@driver.manage.all_cookies).to be_empty + end + + it 'creates SameSite cookies' do + @driver.navigate.to 'http://www.example.com' + + cookie_strict = { + name: 'key', + value: 'value', + same_site: 'Strict' + } + + cookie_lax = { + name: 'key', + value: 'value', + same_site: 'Lax' + } + + @driver.manage.add_cookie(cookie_strict) + @driver.manage.add_cookie(cookie_lax) + + puts cookie_strict[:same_site] + puts cookie_lax[:same_site] + end end diff --git a/examples/ruby/spec/interactions/frames_spec.rb b/examples/ruby/spec/interactions/frames_spec.rb index d7b27b174044..97e89d142cad 100644 --- a/examples/ruby/spec/interactions/frames_spec.rb +++ b/examples/ruby/spec/interactions/frames_spec.rb @@ -2,6 +2,44 @@ require 'spec_helper' -RSpec.describe 'Frames' do - let(:driver) { start_session } +RSpec.describe 'Frames Test' do + it 'interacts with elements inside iframes' do + driver = Selenium::WebDriver.for :chrome + driver.manage.timeouts.implicit_wait = 0.5 + + # Navigate to URL + driver.get('https://www.selenium.dev/selenium/web/iframes.html') + + # Switch to iframe using WebElement + iframe = driver.find_element(id: 'iframe1') + driver.switch_to.frame(iframe) + expect(driver.page_source.include?('We Leave From Here')).to be true + + # Interact with email field + email_element = driver.find_element(id: 'email') + email_element.send_keys('admin@selenium.dev') + email_element.clear + driver.switch_to.default_content + + # Switch to iframe using name + driver.find_element(name: 'iframe1-name') + driver.switch_to.frame(iframe) + expect(driver.page_source.include?('We Leave From Here')).to be true + + email = driver.find_element(id: 'email') + email.send_keys('admin@selenium.dev') + email.clear + driver.switch_to.default_content + + # Switch to iframe using index + driver.switch_to.frame(0) + expect(driver.page_source.include?('We Leave From Here')).to be true + + # Leave frame + driver.switch_to.default_content + expect(driver.page_source.include?('This page has iframes')).to be true + + # Quit the browser + driver.quit + end end diff --git a/website_and_docs/content/documentation/webdriver/interactions/cookies.en.md b/website_and_docs/content/documentation/webdriver/interactions/cookies.en.md index 2565a731e51e..3a431d393313 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/cookies.en.md +++ b/website_and_docs/content/documentation/webdriver/interactions/cookies.en.md @@ -36,19 +36,11 @@ 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#L14-L17" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L18">}} {{< /tab >}} @@ -85,20 +77,11 @@ 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#L19-L24" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L35-L38">}} {{< /tab >}} @@ -138,21 +121,11 @@ 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-L37" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L49-L51">}} {{< /tab >}} @@ -193,21 +166,11 @@ 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#L39-L44" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L61-L62">}} {{< /tab >}} @@ -251,21 +214,11 @@ 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#L54-L60" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L77-L78">}} {{< /tab >}} @@ -349,21 +302,11 @@ namespace SameSiteCookie { } } {{< /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 with sameSite 'Strict' (or) 'Lax' - driver.manage.add_cookie(name: "foo", value: "bar", same_site: "Strict") - driver.manage.add_cookie(name: "foo1", value: "bar", same_site: "Lax") - puts driver.manage.cookie_named('foo') - puts driver.manage.cookie_named('foo1') -ensure - driver.quit -end - {{< /tab >}} + +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\cookies_spec.rb#L62-L81" >}} +{{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L24-L26">}} {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/cookies.ja.md b/website_and_docs/content/documentation/webdriver/interactions/cookies.ja.md index 9a8be028f39f..4a177dc7a777 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/cookies.ja.md +++ b/website_and_docs/content/documentation/webdriver/interactions/cookies.ja.md @@ -33,19 +33,11 @@ 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#L14-L17" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L18">}} {{< /tab >}} @@ -81,20 +73,11 @@ 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#L19-L24" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L35-L38">}} {{< /tab >}} @@ -133,21 +116,11 @@ 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-L37" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L49-L51">}} {{< /tab >}} @@ -187,20 +160,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#L39-L44" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L61-L62">}} @@ -244,20 +205,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#L54-L60" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L77-L78">}} @@ -339,21 +288,11 @@ namespace SameSiteCookie { } } {{< /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 with sameSite 'Strict' (or) 'Lax' - driver.manage.add_cookie(name: "foo", value: "bar", same_site: "Strict") - driver.manage.add_cookie(name: "foo1", value: "bar", same_site: "Lax") - puts driver.manage.cookie_named('foo') - puts driver.manage.cookie_named('foo1') -ensure - driver.quit -end - {{< /tab >}} + + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\cookies_spec.rb#L62-L81" >}} +{{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L24-L26">}} {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/cookies.pt-br.md b/website_and_docs/content/documentation/webdriver/interactions/cookies.pt-br.md index 63d69e63ea17..a8d46463d7d3 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/cookies.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/interactions/cookies.pt-br.md @@ -35,19 +35,11 @@ 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#L14-L17" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L18">}} {{< /tab >}} @@ -83,20 +75,11 @@ 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#L19-L24" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L35-L38">}} {{< /tab >}} @@ -135,21 +118,11 @@ 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-L37" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L49-L51">}} {{< /tab >}} @@ -189,21 +162,11 @@ 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#L39-L44" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L61-L62">}} {{< /tab >}} @@ -246,20 +209,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#L54-L60" >}} {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L77-L78">}} @@ -343,21 +294,10 @@ namespace SameSiteCookie { } } {{< /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 with sameSite 'Strict' (or) 'Lax' - driver.manage.add_cookie(name: "foo", value: "bar", same_site: "Strict") - driver.manage.add_cookie(name: "foo1", value: "bar", same_site: "Lax") - puts driver.manage.cookie_named('foo') - puts driver.manage.cookie_named('foo1') -ensure - driver.quit -end - {{< /tab >}} + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\cookies_spec.rb#L62-L81" >}} +{{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L24-L26">}} {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/cookies.zh-cn.md b/website_and_docs/content/documentation/webdriver/interactions/cookies.zh-cn.md index 2a60ccdd93a9..edfa4558e54d 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/cookies.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/interactions/cookies.zh-cn.md @@ -31,19 +31,11 @@ WebDriver API提供了一种使用内置的方法与Cookie进行交互: {{< 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#L14-L17" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L18">}} {{< /tab >}} @@ -79,20 +71,12 @@ 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#L19-L24" >}} {{< /tab >}} + + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L35-L38">}} {{< /tab >}} @@ -130,21 +114,11 @@ 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-L37" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L49-L51">}} {{< /tab >}} @@ -184,21 +158,11 @@ 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#L39-L44" >}} {{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L61-L62">}} {{< /tab >}} @@ -241,21 +205,11 @@ 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") + +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\cookies_spec.rb#L54-L60" >}} +{{< /tab >}} - # deletes all cookies - driver.manage.delete_all_cookies -ensure - driver.quit -end - {{< /tab >}} {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L77-L78">}} {{< /tab >}} @@ -337,21 +291,11 @@ namespace SameSiteCookie { } } {{< /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 with sameSite 'Strict' (or) 'Lax' - driver.manage.add_cookie(name: "foo", value: "bar", same_site: "Strict") - driver.manage.add_cookie(name: "foo1", value: "bar", same_site: "Lax") - puts driver.manage.cookie_named('foo') - puts driver.manage.cookie_named('foo1') -ensure - driver.quit -end - {{< /tab >}} + + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\cookies_spec.rb#L62-L81" >}} +{{< /tab >}} + {{< tab header="JavaScript" text=true >}} {{< gh-codeblock path="/examples/javascript/test/interactions/cookies.spec.js#L24-L26">}} {{< /tab >}} diff --git a/website_and_docs/content/documentation/webdriver/interactions/frames.en.md b/website_and_docs/content/documentation/webdriver/interactions/frames.en.md index 4c02033c24c7..32e1b20034fa 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/frames.en.md +++ b/website_and_docs/content/documentation/webdriver/interactions/frames.en.md @@ -88,16 +88,11 @@ driver.find_element(By.TAG_NAME, 'button').click() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L38-L46" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Store iframe web element -iframe = driver.find_element(:css,'#modal > iframe') - # Switch to the frame -driver.switch_to.frame iframe +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L13-L22" >}} +{{< /tab >}} - # Now, Click on the button -driver.find_element(:tag_name,'button').click - {{< /tab >}} {{< tab header="JavaScript" >}} // Store the web element const iframe = driver.findElement(By.css('#modal > iframe')); @@ -140,24 +135,12 @@ driver.find_element(By.TAG_NAME, 'button').click() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L50-L58" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Switch by ID -driver.switch_to.frame 'buttonframe' - # Now, Click on the button -driver.find_element(:tag_name,'button').click - {{< /tab >}} - {{< tab header="JavaScript" >}} -// Using the ID -await driver.switchTo().frame('buttonframe'); - -// Or using the name instead -await driver.switchTo().frame('myframe'); +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L24-L32" >}} +{{< /tab >}} -// Now we can click the button -await driver.findElement(By.css('button')).click(); - {{< /tab >}} - {{< tab header="Kotlin" >}} +{{< tab header="Kotlin" >}} //Using the ID driver.switchTo().frame("buttonframe") @@ -181,13 +164,20 @@ queried using _window.frames_ in JavaScript. {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L62-L63" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Switch to the second frame -driver.switch_to.frame(1) + {{< tab header="Python" >}} + # missing code + {{< /tab >}} + {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}} {{< /tab >}} + + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L34-L36" >}} +{{< /tab >}} + + {{< tab header="JavaScript" >}} // Switches to the second frame await driver.switchTo().frame(1); @@ -217,10 +207,11 @@ driver.switch_to.default_content() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L66-L67" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Return to the top level -driver.switch_to.default_content - {{< /tab >}} + + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L38-L40" >}} +{{< /tab >}} + {{< tab header="JavaScript" >}} // Return to the top level await driver.switchTo().defaultContent(); diff --git a/website_and_docs/content/documentation/webdriver/interactions/frames.ja.md b/website_and_docs/content/documentation/webdriver/interactions/frames.ja.md index 97ae27619657..1a283d56dad1 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/frames.ja.md +++ b/website_and_docs/content/documentation/webdriver/interactions/frames.ja.md @@ -77,16 +77,11 @@ driver.find_element(By.TAG_NAME, 'button').click() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L38-L46" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Store iframe web element -iframe = driver.find_element(:css,'#modal > iframe') - # Switch to the frame -driver.switch_to.frame iframe + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L13-L22" >}} +{{< /tab >}} - # Now, Click on the button -driver.find_element(:tag_name,'button').click - {{< /tab >}} {{< tab header="JavaScript" >}} // Store the web element const iframe = driver.findElement(By.css('#modal > iframe')); @@ -118,6 +113,7 @@ FrameまたはiFrameにidまたはname属性がある場合、代わりにこれ {{< tab header="Java" text=true >}} {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L50-L58" >}} {{< /tab >}} + {{< tab header="Python" >}} # Switch frame by id driver.switch_to.frame('buttonframe') @@ -125,9 +121,16 @@ driver.switch_to.frame('buttonframe') # Now, Click on the button driver.find_element(By.TAG_NAME, 'button').click() {{< /tab >}} + {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L50-L58" >}} {{< /tab >}} + +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L24-L32" >}} +{{< /tab >}} + + {{< tab header="JavaScript" >}} // Using the ID await driver.switchTo().frame('buttonframe'); @@ -158,20 +161,24 @@ JavaScriptの _window.frames_ を使用して照会できるように、Frameの {{< tab header="Java" text=true >}} {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L62-L63" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Switch to the second frame -driver.switch_to.frame(1) - {{< /tab >}} - {{< tab header="CSharp" text=true >}} -{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}} -{{< /tab >}} - {{< tab header="Python" >}} + +{{< tab header="Python" >}} # switching to second iframe based on index iframe = driver.find_elements(By.TAG_NAME,'iframe')[1] # switch to selected iframe driver.switch_to.frame(iframe) {{< /tab >}} + + {{< tab header="CSharp" text=true >}} +{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}} +{{< /tab >}} + +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L34-L36" >}} +{{< /tab >}} + + {{< tab header="JavaScript" >}} // Switches to the second frame await driver.switchTo().frame(1); @@ -198,10 +205,11 @@ driver.switch_to.default_content() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L66-L67" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Return to the top level -driver.switch_to.default_content - {{< /tab >}} + + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L38-L40" >}} +{{< /tab >}} + {{< tab header="JavaScript" >}} // Return to the top level await driver.switchTo().defaultContent(); diff --git a/website_and_docs/content/documentation/webdriver/interactions/frames.pt-br.md b/website_and_docs/content/documentation/webdriver/interactions/frames.pt-br.md index 0fd61db35931..e0576c8b2d81 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/frames.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/interactions/frames.pt-br.md @@ -85,16 +85,9 @@ driver.find_element(By.TAG_NAME, 'button').click() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L38-L46" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Store iframe web element -iframe = driver.find_element(:css,'#modal > iframe') - - # Switch to the frame -driver.switch_to.frame iframe - - # Now, Click on the button -driver.find_element(:tag_name,'button').click - {{< /tab >}} +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L13-L22" >}} +{{< /tab >}} {{< tab header="JavaScript" >}} // Store the web element const iframe = driver.findElement(By.css('#modal > iframe')); @@ -136,23 +129,12 @@ driver.find_element(By.TAG_NAME, 'button').click() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L50-L58" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Switch by ID -driver.switch_to.frame 'buttonframe' - - # Now, Click on the button -driver.find_element(:tag_name,'button').click - {{< /tab >}} - {{< tab header="JavaScript" >}} -// Using the ID -await driver.switchTo().frame('buttonframe'); + +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L24-L32" >}} +{{< /tab >}} -// Or using the name instead -await driver.switchTo().frame('myframe'); -// Now we can click the button -await driver.findElement(By.css('button')).click(); - {{< /tab >}} {{< tab header="Kotlin" >}} //Using the ID driver.switchTo().frame("buttonframe") @@ -174,20 +156,23 @@ consultado usando _window.frames_ em JavaScript. {{< tab header="Java" text=true >}} {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L62-L63" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Switch to the second frame -driver.switch_to.frame(1) - {{< /tab >}} - {{< tab header="CSharp" text=true >}} -{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}} -{{< /tab >}} - {{< tab header="Python" >}} + {{< tab header="Python" >}} # switching to second iframe based on index iframe = driver.find_elements(By.TAG_NAME,'iframe')[1] # switch to selected iframe driver.switch_to.frame(iframe) {{< /tab >}} + + {{< tab header="CSharp" text=true >}} +{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}} +{{< /tab >}} + + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L34-L36" >}} +{{< /tab >}} + + {{< tab header="JavaScript" >}} // Switches to the second frame await driver.switchTo().frame(1); @@ -215,10 +200,9 @@ driver.switch_to.default_content() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L66-L67" >}} {{< /tab >}} - {{< tab header="Ruby" >}} - # Return to the top level -driver.switch_to.default_content - {{< /tab >}} + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L38-L40" >}} +{{< /tab >}} {{< tab header="JavaScript" >}} // Return to the top level await driver.switchTo().defaultContent(); diff --git a/website_and_docs/content/documentation/webdriver/interactions/frames.zh-cn.md b/website_and_docs/content/documentation/webdriver/interactions/frames.zh-cn.md index af55faf58226..8de76aba8971 100644 --- a/website_and_docs/content/documentation/webdriver/interactions/frames.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/interactions/frames.zh-cn.md @@ -78,26 +78,11 @@ driver.find_element(By.TAG_NAME, 'button').click() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L38-L46" >}} {{< /tab >}} -{{< tab header="Ruby" >}} - # Store iframe web element -iframe = driver.find_element(:css,'#modal> iframe') - - # 切换到 frame -driver.switch_to.frame iframe - # 单击按钮 -driver.find_element(:tag_name,'button').click +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L13-L22" >}} {{< /tab >}} -{{< tab header="JavaScript" >}} -// 存储网页元素 -const iframe = driver.findElement(By.css('#modal> iframe')); - -// 切换到 frame -await driver.switchTo().frame(iframe); -// 现在可以点击按钮 -await driver.findElement(By.css('button')).click(); -{{< /tab >}} {{< tab header="Kotlin" >}} // 存储网页元素 val iframe = driver.findElement(By.cssSelector("#modal>iframe")) @@ -129,23 +114,11 @@ driver.find_element(By.TAG_NAME, 'button').click() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L50-L58" >}} {{< /tab >}} -{{< tab header="Ruby" >}} - # Switch by ID -driver.switch_to.frame 'buttonframe' - # 单击按钮 -driver.find_element(:tag_name,'button').click +{{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L24-L32" >}} {{< /tab >}} -{{< tab header="JavaScript" >}} -// 使用 ID -await driver.switchTo().frame('buttonframe'); - -// 或者使用 name 代替 -await driver.switchTo().frame('myframe'); -// 现在可以点击按钮 -await driver.findElement(By.css('button')).click(); -{{< /tab >}} {{< tab header="Kotlin" >}} // 使用 ID driver.switchTo().frame("buttonframe") @@ -168,13 +141,7 @@ _window.frames_ 进行查询. {{< tab header="Java" text=true >}} {{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L62-L63" >}} {{< /tab >}} -{{< tab header="Ruby" >}} - # 切换到第 2 个框架 -driver.switch_to.frame(1) -{{< /tab >}} - {{< tab header="CSharp" text=true >}} -{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}} -{{< /tab >}} + {{< tab header="Python" >}} # 基于索引切换到第 2 个 iframe iframe = driver.find_elements(By.TAG_NAME,'iframe')[1] @@ -182,6 +149,17 @@ iframe = driver.find_elements(By.TAG_NAME,'iframe')[1] # 切换到选择的 iframe driver.switch_to.frame(iframe) {{< /tab >}} + + + {{< tab header="CSharp" text=true >}} +{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}} +{{< /tab >}} + + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L34-L36" >}} +{{< /tab >}} + + {{< tab header="JavaScript" >}} // 切换到第 2 个框架 await driver.switchTo().frame(1); @@ -208,10 +186,11 @@ driver.switch_to.default_content() {{< tab header="CSharp" text=true >}} {{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L66-L67" >}} {{< /tab >}} -{{< tab header="Ruby" >}} - # 回到顶层 -driver.switch_to.default_content + + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L38-L40" >}} {{< /tab >}} + {{< tab header="JavaScript" >}} // 回到顶层 await driver.switchTo().defaultContent(); diff --git a/website_and_docs/hugo.toml b/website_and_docs/hugo.toml index fa46c474e1e2..ff367fd7b71a 100644 --- a/website_and_docs/hugo.toml +++ b/website_and_docs/hugo.toml @@ -6,7 +6,7 @@ enableRobotsTXT = true # Will give values to .Lastmod etc. enableGitInfo = true -#ignoreErrors = ["error-remote-getjson"] +ignoreErrors = ["error-remote-getjson"] # Language settings # contentDir = "content/en" defaultContentLanguage = "en"