Skip to content

Commit e22d14d

Browse files
added frame code
1 parent 0e7df55 commit e22d14d

File tree

6 files changed

+132
-132
lines changed

6 files changed

+132
-132
lines changed

examples/ruby/spec/interactions/frames_spec.rb

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,44 @@
22

33
require 'spec_helper'
44

5-
RSpec.describe 'Frames' do
6-
let(:driver) { start_session }
5+
describe 'Frames Test' do
6+
it 'interacts with elements inside iframes' do
7+
driver = Selenium::WebDriver.for :chrome
8+
driver.manage.timeouts.implicit_wait = 0.5
9+
10+
# Navigate to URL
11+
driver.get('https://www.selenium.dev/selenium/web/iframes.html')
12+
13+
# Switch to iframe using WebElement
14+
iframe = driver.find_element(id: 'iframe1')
15+
driver.switch_to.frame(iframe)
16+
expect(driver.page_source.include?('We Leave From Here')).to be true
17+
18+
# Interact with email field
19+
email_element = driver.find_element(id: 'email')
20+
email_element.send_keys('[email protected]')
21+
email_element.clear
22+
driver.switch_to.default_content
23+
24+
# Switch to iframe using name
25+
driver.find_element(name: 'iframe1-name')
26+
driver.switch_to.frame(iframe)
27+
expect(driver.page_source.include?('We Leave From Here')).to be true
28+
29+
email = driver.find_element(id: 'email')
30+
email.send_keys('[email protected]')
31+
email.clear
32+
driver.switch_to.default_content
33+
34+
# Switch to iframe using index
35+
driver.switch_to.frame(0)
36+
expect(driver.page_source.include?('We Leave From Here')).to be true
37+
38+
# Leave frame
39+
driver.switch_to.default_content
40+
expect(driver.page_source.include?('This page has iframes')).to be true
41+
42+
# Quit the browser
43+
driver.quit
44+
end
745
end

website_and_docs/content/documentation/webdriver/interactions/frames.en.md

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,11 @@ driver.find_element(By.TAG_NAME, 'button').click()
8888
{{< tab header="CSharp" text=true >}}
8989
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L38-L46" >}}
9090
{{< /tab >}}
91-
{{< tab header="Ruby" >}}
92-
# Store iframe web element
93-
iframe = driver.find_element(:css,'#modal > iframe')
9491

95-
# Switch to the frame
96-
driver.switch_to.frame iframe
92+
{{< tab header="Ruby" text=true >}}
93+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L13-L22" >}}
94+
{{< /tab >}}
9795

98-
# Now, Click on the button
99-
driver.find_element(:tag_name,'button').click
100-
{{< /tab >}}
10196
{{< tab header="JavaScript" >}}
10297
// Store the web element
10398
const iframe = driver.findElement(By.css('#modal > iframe'));
@@ -140,24 +135,12 @@ driver.find_element(By.TAG_NAME, 'button').click()
140135
{{< tab header="CSharp" text=true >}}
141136
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L50-L58" >}}
142137
{{< /tab >}}
143-
{{< tab header="Ruby" >}}
144-
# Switch by ID
145-
driver.switch_to.frame 'buttonframe'
146138

147-
# Now, Click on the button
148-
driver.find_element(:tag_name,'button').click
149-
{{< /tab >}}
150-
{{< tab header="JavaScript" >}}
151-
// Using the ID
152-
await driver.switchTo().frame('buttonframe');
153-
154-
// Or using the name instead
155-
await driver.switchTo().frame('myframe');
139+
{{< tab header="Ruby" text=true >}}
140+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L24-L32" >}}
141+
{{< /tab >}}
156142

157-
// Now we can click the button
158-
await driver.findElement(By.css('button')).click();
159-
{{< /tab >}}
160-
{{< tab header="Kotlin" >}}
143+
{{< tab header="Kotlin" >}}
161144
//Using the ID
162145
driver.switchTo().frame("buttonframe")
163146

@@ -181,13 +164,20 @@ queried using _window.frames_ in JavaScript.
181164
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L62-L63" >}}
182165
{{< /tab >}}
183166

184-
{{< tab header="Ruby" >}}
185-
# Switch to the second frame
186-
driver.switch_to.frame(1)
167+
{{< tab header="Python" >}}
168+
# missing code
169+
187170
{{< /tab >}}
171+
188172
{{< tab header="CSharp" text=true >}}
189173
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}}
190174
{{< /tab >}}
175+
176+
{{< tab header="Ruby" text=true >}}
177+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L34-L36" >}}
178+
{{< /tab >}}
179+
180+
191181
{{< tab header="JavaScript" >}}
192182
// Switches to the second frame
193183
await driver.switchTo().frame(1);
@@ -217,10 +207,11 @@ driver.switch_to.default_content()
217207
{{< tab header="CSharp" text=true >}}
218208
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L66-L67" >}}
219209
{{< /tab >}}
220-
{{< tab header="Ruby" >}}
221-
# Return to the top level
222-
driver.switch_to.default_content
223-
{{< /tab >}}
210+
211+
{{< tab header="Ruby" text=true >}}
212+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L38-L40" >}}
213+
{{< /tab >}}
214+
224215
{{< tab header="JavaScript" >}}
225216
// Return to the top level
226217
await driver.switchTo().defaultContent();

website_and_docs/content/documentation/webdriver/interactions/frames.ja.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,11 @@ driver.find_element(By.TAG_NAME, 'button').click()
7777
{{< tab header="CSharp" text=true >}}
7878
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L38-L46" >}}
7979
{{< /tab >}}
80-
{{< tab header="Ruby" >}}
81-
# Store iframe web element
82-
iframe = driver.find_element(:css,'#modal > iframe')
8380

84-
# Switch to the frame
85-
driver.switch_to.frame iframe
81+
{{< tab header="Ruby" text=true >}}
82+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L13-L22" >}}
83+
{{< /tab >}}
8684

87-
# Now, Click on the button
88-
driver.find_element(:tag_name,'button').click
89-
{{< /tab >}}
9085
{{< tab header="JavaScript" >}}
9186
// Store the web element
9287
const iframe = driver.findElement(By.css('#modal > iframe'));
@@ -118,16 +113,24 @@ FrameまたはiFrameにidまたはname属性がある場合、代わりにこれ
118113
{{< tab header="Java" text=true >}}
119114
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L50-L58" >}}
120115
{{< /tab >}}
116+
121117
{{< tab header="Python" >}}
122118
# Switch frame by id
123119
driver.switch_to.frame('buttonframe')
124120

125121
# Now, Click on the button
126122
driver.find_element(By.TAG_NAME, 'button').click()
127123
{{< /tab >}}
124+
128125
{{< tab header="CSharp" text=true >}}
129126
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L50-L58" >}}
130127
{{< /tab >}}
128+
129+
{{< tab header="Ruby" text=true >}}
130+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L24-L32" >}}
131+
{{< /tab >}}
132+
133+
131134
{{< tab header="JavaScript" >}}
132135
// Using the ID
133136
await driver.switchTo().frame('buttonframe');
@@ -158,20 +161,24 @@ JavaScriptの _window.frames_ を使用して照会できるように、Frameの
158161
{{< tab header="Java" text=true >}}
159162
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L62-L63" >}}
160163
{{< /tab >}}
161-
{{< tab header="Ruby" >}}
162-
# Switch to the second frame
163-
driver.switch_to.frame(1)
164-
{{< /tab >}}
165-
{{< tab header="CSharp" text=true >}}
166-
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}}
167-
{{< /tab >}}
168-
{{< tab header="Python" >}}
164+
165+
{{< tab header="Python" >}}
169166
# switching to second iframe based on index
170167
iframe = driver.find_elements(By.TAG_NAME,'iframe')[1]
171168

172169
# switch to selected iframe
173170
driver.switch_to.frame(iframe)
174171
{{< /tab >}}
172+
173+
{{< tab header="CSharp" text=true >}}
174+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}}
175+
{{< /tab >}}
176+
177+
{{< tab header="Ruby" text=true >}}
178+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L34-L36" >}}
179+
{{< /tab >}}
180+
181+
175182
{{< tab header="JavaScript" >}}
176183
// Switches to the second frame
177184
await driver.switchTo().frame(1);
@@ -198,10 +205,11 @@ driver.switch_to.default_content()
198205
{{< tab header="CSharp" text=true >}}
199206
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L66-L67" >}}
200207
{{< /tab >}}
201-
{{< tab header="Ruby" >}}
202-
# Return to the top level
203-
driver.switch_to.default_content
204-
{{< /tab >}}
208+
209+
{{< tab header="Ruby" text=true >}}
210+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L38-L40" >}}
211+
{{< /tab >}}
212+
205213
{{< tab header="JavaScript" >}}
206214
// Return to the top level
207215
await driver.switchTo().defaultContent();

website_and_docs/content/documentation/webdriver/interactions/frames.pt-br.md

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,9 @@ driver.find_element(By.TAG_NAME, 'button').click()
8585
{{< tab header="CSharp" text=true >}}
8686
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L38-L46" >}}
8787
{{< /tab >}}
88-
{{< tab header="Ruby" >}}
89-
# Store iframe web element
90-
iframe = driver.find_element(:css,'#modal > iframe')
91-
92-
# Switch to the frame
93-
driver.switch_to.frame iframe
94-
95-
# Now, Click on the button
96-
driver.find_element(:tag_name,'button').click
97-
{{< /tab >}}
88+
{{< tab header="Ruby" text=true >}}
89+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L13-L22" >}}
90+
{{< /tab >}}
9891
{{< tab header="JavaScript" >}}
9992
// Store the web element
10093
const iframe = driver.findElement(By.css('#modal > iframe'));
@@ -136,23 +129,12 @@ driver.find_element(By.TAG_NAME, 'button').click()
136129
{{< tab header="CSharp" text=true >}}
137130
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L50-L58" >}}
138131
{{< /tab >}}
139-
{{< tab header="Ruby" >}}
140-
# Switch by ID
141-
driver.switch_to.frame 'buttonframe'
142-
143-
# Now, Click on the button
144-
driver.find_element(:tag_name,'button').click
145-
{{< /tab >}}
146-
{{< tab header="JavaScript" >}}
147-
// Using the ID
148-
await driver.switchTo().frame('buttonframe');
132+
133+
{{< tab header="Ruby" text=true >}}
134+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L24-L32" >}}
135+
{{< /tab >}}
149136

150-
// Or using the name instead
151-
await driver.switchTo().frame('myframe');
152137

153-
// Now we can click the button
154-
await driver.findElement(By.css('button')).click();
155-
{{< /tab >}}
156138
{{< tab header="Kotlin" >}}
157139
//Using the ID
158140
driver.switchTo().frame("buttonframe")
@@ -174,20 +156,23 @@ consultado usando _window.frames_ em JavaScript.
174156
{{< tab header="Java" text=true >}}
175157
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/FramesTest.java#L62-L63" >}}
176158
{{< /tab >}}
177-
{{< tab header="Ruby" >}}
178-
# Switch to the second frame
179-
driver.switch_to.frame(1)
180-
{{< /tab >}}
181-
{{< tab header="CSharp" text=true >}}
182-
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}}
183-
{{< /tab >}}
184-
{{< tab header="Python" >}}
159+
{{< tab header="Python" >}}
185160
# switching to second iframe based on index
186161
iframe = driver.find_elements(By.TAG_NAME,'iframe')[1]
187162

188163
# switch to selected iframe
189164
driver.switch_to.frame(iframe)
190165
{{< /tab >}}
166+
167+
{{< tab header="CSharp" text=true >}}
168+
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L62-L63" >}}
169+
{{< /tab >}}
170+
171+
{{< tab header="Ruby" text=true >}}
172+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L34-L36" >}}
173+
{{< /tab >}}
174+
175+
191176
{{< tab header="JavaScript" >}}
192177
// Switches to the second frame
193178
await driver.switchTo().frame(1);
@@ -215,10 +200,9 @@ driver.switch_to.default_content()
215200
{{< tab header="CSharp" text=true >}}
216201
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/FramesTest.cs#L66-L67" >}}
217202
{{< /tab >}}
218-
{{< tab header="Ruby" >}}
219-
# Return to the top level
220-
driver.switch_to.default_content
221-
{{< /tab >}}
203+
{{< tab header="Ruby" text=true >}}
204+
{{< gh-codeblock path="examples\ruby\spec\interactions\frames_spec.rb#L38-L40" >}}
205+
{{< /tab >}}
222206
{{< tab header="JavaScript" >}}
223207
// Return to the top level
224208
await driver.switchTo().defaultContent();

0 commit comments

Comments
 (0)