forked from SeleniumHQ/seleniumhq.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframes_spec.rb
More file actions
45 lines (35 loc) · 1.36 KB
/
frames_spec.rb
File metadata and controls
45 lines (35 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true
require 'spec_helper'
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('[email protected]')
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('[email protected]')
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