Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/spec/integration/selenium/webdriver/navigation_spec.rb
1864 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
require_relative 'spec_helper'
21
module Selenium
22
module WebDriver
23
describe Navigation do
24
it 'navigates back and forward' do
25
form_title = 'We Leave From Here'
26
result_title = 'We Arrive Here'
27
form_url = url_for 'formPage.html'
28
result_url = url_for 'resultPage.html'
29
30
driver.navigate.to form_url
31
expect(driver.title).to eq(form_title)
32
33
driver.find_element(id: 'imageButton').click
34
wait.until { driver.title != form_title }
35
36
expect(driver.current_url).to include(result_url)
37
expect(driver.title).to eq(result_title)
38
39
driver.navigate.back
40
41
expect(driver.current_url).to include(form_url)
42
expect(driver.title).to eq(form_title)
43
44
driver.navigate.forward
45
expect(driver.current_url).to include(result_url)
46
expect(driver.title).to eq(result_title)
47
end
48
49
it 'refreshes the page' do
50
changed_title = 'Changed'
51
52
driver.navigate.to url_for('javascriptPage.html')
53
driver.find_element(link_text: 'Change the page title!').click
54
expect(driver.title).to eq(changed_title)
55
56
driver.navigate.refresh
57
wait.until { driver.title != changed_title }
58
59
expect(driver.title).to eq('Testing Javascript')
60
end
61
end
62
end # WebDriver
63
end # Selenium
64
65