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
42 lines (34 loc) · 1.34 KB
/
frames_spec.rb
File metadata and controls
42 lines (34 loc) · 1.34 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
# frozen_string_literal: true
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('[email protected]')
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('[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
end
end