-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathfinders_spec.rb
42 lines (33 loc) · 1.16 KB
/
finders_spec.rb
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 'Element Finders' do
let(:driver) { start_session }
context 'without executing finders', skip: 'these are just examples, not actual tests' do
it 'finds the first matching element' do
driver.find_element(class: 'tomatoes')
end
it 'uses a subset of the dom to find an element' do
fruits = driver.find_element(id: 'fruits')
fruits.find_element(class: 'tomatoes')
end
it 'uses an optimized locator' do
driver.find_element(css: '#fruits .tomatoes')
end
it 'finds all matching elements' do
driver.find_elements(tag_name: 'li')
end
it 'gets an element from a collection' do
elements = driver.find_elements(:tag_name, 'p')
elements.each { |e| puts e.text }
end
it 'finds element from element' do
element = driver.find_element(:tag_name, 'div')
elements = element.find_elements(:tag_name, 'p')
elements.each { |e| puts e.text }
end
it 'find active element' do
driver.find_element(css: '[name="q"]').send_keys('webElement')
driver.switch_to.active_element.attribute('title')
end
end
end