"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/py/test/selenium/webdriver/common/timeout_tests.py" (17 Feb 2023, 2290 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
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
19 import pytest
20
21 from selenium.webdriver.common.timeouts import Timeouts
22
23
24 def test_should_create_timeouts_object():
25 implicit_wait = 10
26 page_load = 10
27 script = 10
28 timeouts = Timeouts(implicit_wait=implicit_wait, page_load=page_load, script=script)
29
30 assert implicit_wait == timeouts.implicit_wait
31 assert page_load == timeouts.page_load
32 assert script == timeouts.script
33
34
35 def test_should_error_if_implicit_wait_isnt_a_number():
36 with pytest.raises(TypeError):
37 Timeouts(implicit_wait="abc")
38
39 timeout = Timeouts(implicit_wait=0)
40 with pytest.raises(TypeError):
41 timeout.implicit_wait = "abc"
42
43
44 def test_should_error_if_page_load_isnt_a_number():
45 with pytest.raises(TypeError):
46 Timeouts(page_load="abc")
47
48 timeout = Timeouts(page_load=0)
49 with pytest.raises(TypeError):
50 timeout.page_load = "abc"
51
52
53 def test_should_error_if_script_isnt_a_number():
54 with pytest.raises(TypeError):
55 Timeouts(script="abc")
56
57 timeout = Timeouts(script=0)
58 with pytest.raises(TypeError):
59 timeout.script = "abc"
60
61
62 def test_should_get_timeouts_without_setting_them(driver):
63 results = driver.timeouts
64 assert results.implicit_wait == 0
65 assert results.page_load == 300
66 assert results.script == 30
67
68
69 def test_should_set_and_get_timeouts_on_remote_end(driver):
70 timeout = Timeouts(implicit_wait=10)
71 driver.timeouts = timeout
72 result = driver.timeouts
73 assert result.implicit_wait == timeout.implicit_wait