Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/py/test/selenium/webdriver/common/page_loading_tests.py
1865 views
1
# Licensed to the Software Freedom Conservancy (SFC) under one
2
# or more contributor license agreements. See the NOTICE file
3
# distributed with this work for additional information
4
# regarding copyright ownership. The SFC licenses this file
5
# to you under the Apache License, Version 2.0 (the
6
# "License"); you may not use this file except in compliance
7
# with the License. You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing,
12
# software distributed under the License is distributed on an
13
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
# KIND, either express or implied. See the License for the
15
# specific language governing permissions and limitations
16
# under the License.
17
18
# import pytest
19
#
20
# from selenium.common.exceptions import WebDriverException
21
# from selenium.webdriver.common.by import By
22
# from selenium.webdriver.support.wait import WebDriverWait
23
# from selenium.webdriver.support import expected_conditions as EC
24
25
26
def test_should_wait_for_document_to_be_loaded(driver, pages):
27
pages.load("simpleTest.html")
28
assert driver.title == "Hello WebDriver"
29
30
31
# Disabled till Java WebServer is used
32
# def test_should_follow_redirects_sent_in_the_http_response_headers(driver, pages):
33
# pages.load("redirect.html")
34
# assert driver.title == "We Arrive Here"
35
36
37
# Disabled till the Java WebServer is used
38
# def test_should_follow_meta_redirects(driver, pages):
39
# pages.load("metaRedirect.html")
40
# assert driver.title == "We Arrive Here"
41
42
43
# def test_should_be_able_to_get_afragment_on_the_current_page(driver, pages):
44
# pages.load("xhtmlTest.html")
45
# location = driver.current_url
46
# driver.get(location + "#text")
47
# driver.find_element(by=By.ID, value="id1")
48
49
50
# @pytest.mark.xfail_firefox(raises=WebDriverException)
51
# @pytest.mark.xfail_remote(raises=WebDriverException)
52
# def test_should_return_when_getting_aurl_that_does_not_resolve(driver):
53
# # Of course, we're up the creek if this ever does get registered
54
# driver.get("http://www.thisurldoesnotexist.comx/")
55
56
57
# @pytest.mark.xfail_firefox(raises=WebDriverException)
58
# @pytest.mark.xfail_remote(raises=WebDriverException)
59
# def test_should_return_when_getting_aurl_that_does_not_connect(driver):
60
# # Here's hoping that there's nothing here. There shouldn't be
61
# driver.get("http://localhost:3001")
62
63
# def test_should_be_able_to_load_apage_with_framesets_and_wait_until_all_frames_are_loaded() {
64
# driver.get(pages.framesetPage)
65
#
66
# driver.switchTo().frame(0)
67
# WebElement pageNumber = driver.findElement(By.xpath("#span[@id='pageNumber']"))
68
# self.assertEqual((pageNumber.getText().trim(), equalTo("1"))
69
#
70
# driver.switchTo().defaultContent().switchTo().frame(1)
71
# pageNumber = driver.findElement(By.xpath("#span[@id='pageNumber']"))
72
# self.assertEqual((pageNumber.getText().trim(), equalTo("2"))
73
74
# Need to implement this decorator
75
# @NeedsFreshDriver
76
# def test_sould_do_nothing_if_there_is_nothing_to_go_back_to() {
77
# originalTitle = driver.getTitle();
78
# driver.get(pages.formPage);
79
# driver.back();
80
# # We may have returned to the browser's home page
81
# self.assertEqual(driver.title, anyOf(equalTo(originalTitle), equalTo("We Leave From Here")));
82
83
84
# @pytest.mark.xfail_safari
85
# def test_should_be_able_to_navigate_back_in_the_browser_history(driver, pages):
86
# pages.load("formPage.html")
87
88
# driver.find_element(by=By.ID, value="imageButton").submit()
89
# WebDriverWait(driver, 3).until(EC.title_is("We Arrive Here"))
90
91
# driver.back()
92
# assert driver.title == "We Leave From Here"
93
94
95
# @pytest.mark.xfail_safari
96
# def test_should_be_able_to_navigate_back_in_the_browser_history_in_presence_of_iframes(driver, pages):
97
# pages.load("xhtmlTest.html")
98
99
# driver.find_element(by=By.NAME, value="sameWindow").click()
100
101
# assert driver.title == "This page has iframes"
102
103
# driver.back()
104
# assert driver.title == "XHTML Test Page"
105
106
107
# def test_should_be_able_to_navigate_forwards_in_the_browser_history(driver, pages):
108
# pages.load("formPage.html")
109
110
# driver.find_element(by=By.ID, value="imageButton").submit()
111
# WebDriverWait(driver, 3).until(EC.title_is("We Arrive Here"))
112
113
# driver.back()
114
# assert driver.title == "We Leave From Here"
115
116
# driver.forward()
117
# assert driver.title == "We Arrive Here"
118
119
120
# @pytest.mark.xfail_ie
121
# @pytest.mark.xfail_firefox(run=False)
122
# @pytest.mark.xfail_remote(run=False)
123
# @pytest.mark.xfail_chrome(run=False)
124
# @pytest.mark.xfail_edge(run=False)
125
# def test_should_not_hang_if_document_open_call_is_never_followed_by_document_close_call(driver, pages):
126
# pages.load("document_write_in_onload.html")
127
# driver.find_element(By.XPATH, "//body")
128
129
130
# def test_should_be_able_to_refresh_apage(driver, pages):
131
# pages.load("xhtmlTest.html")
132
133
# driver.refresh()
134
135
# assert driver.title == "XHTML Test Page"
136
137