|
| 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 TimeoutException |
| 21 | +from selenium.webdriver.support.wait import WebDriverWait |
| 22 | +from selenium.webdriver.support import expected_conditions as EC |
| 23 | +from selenium.webdriver.common.by import By |
| 24 | +from selenium.webdriver.remote.webelement import WebElement |
| 25 | + |
| 26 | + |
| 27 | +def test_any_of_true(driver, pages): |
| 28 | + pages.load("simpleTest.html") |
| 29 | + WebDriverWait(driver, 0.1).until(EC.any_of( |
| 30 | + EC.title_is("Nope"), EC.title_is("Hello WebDriver"))) |
| 31 | + |
| 32 | + |
| 33 | +def test_any_of_false(driver, pages): |
| 34 | + pages.load("simpleTest.html") |
| 35 | + with pytest.raises(TimeoutException): |
| 36 | + WebDriverWait(driver, 0.1).until(EC.any_of( |
| 37 | + EC.title_is("Nope"), EC.title_is("Still Nope"))) |
| 38 | + |
| 39 | + |
| 40 | +def test_all_of_true(driver, pages): |
| 41 | + pages.load("simpleTest.html") |
| 42 | + results = WebDriverWait(driver, 0.1).until(EC.all_of( |
| 43 | + EC.title_is("Hello WebDriver"), |
| 44 | + EC.visibility_of_element_located((By.ID, "oneline")))) |
| 45 | + assert results[0] is True |
| 46 | + assert type(results[1]) is WebElement |
| 47 | + |
| 48 | + |
| 49 | +def test_all_of_false(driver, pages): |
| 50 | + pages.load("simpleTest.html") |
| 51 | + with pytest.raises(TimeoutException): |
| 52 | + WebDriverWait(driver, 0.1).until(EC.all_of( |
| 53 | + EC.title_is("Nope"), EC.title_is("Still Nope"))) |
| 54 | + |
| 55 | + |
| 56 | +def test_none_of_true(driver, pages): |
| 57 | + pages.load("simpleTest.html") |
| 58 | + WebDriverWait(driver, 0.1).until(EC.none_of( |
| 59 | + EC.title_is("Nope"), EC.title_is("Still Nope"))) |
| 60 | + |
| 61 | + |
| 62 | +def test_none_of_false(driver, pages): |
| 63 | + pages.load("simpleTest.html") |
| 64 | + with pytest.raises(TimeoutException): |
| 65 | + WebDriverWait(driver, 0.1).until(EC.none_of( |
| 66 | + EC.title_is("Nope"), EC.title_is("Hello WebDriver"))) |
0 commit comments