diff --git a/examples/ruby/Gemfile b/examples/ruby/Gemfile index 17d408f72607..dd23c86ad048 100644 --- a/examples/ruby/Gemfile +++ b/examples/ruby/Gemfile @@ -7,5 +7,5 @@ gem 'rake', '~> 13.0' gem 'rspec', '~> 3.0' gem 'rubocop', '~> 1.35' gem 'rubocop-rspec', '~> 3.0' -gem 'selenium-devtools', '= 0.133.0' -gem 'selenium-webdriver', '= 4.29.1' +gem 'selenium-devtools', '= 0.134.0' +gem 'selenium-webdriver', '= 4.30.0' diff --git a/examples/ruby/spec/interactions/frames_spec.rb b/examples/ruby/spec/interactions/frames_spec.rb index d7b27b174044..f505d2032782 100644 --- a/examples/ruby/spec/interactions/frames_spec.rb +++ b/examples/ruby/spec/interactions/frames_spec.rb @@ -3,5 +3,40 @@ require 'spec_helper' RSpec.describe 'Frames' do + #set session let(:driver) { start_session } + let(:wait) { Selenium::WebDriver::Wait.new(timeout: 2) } + + it 'interacts with elements inside iframes' do + #navigate to web page + driver.navigate.to '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 + iframe=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 + end end 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"