Path: blob/trunk/py/test/selenium/webdriver/common/clear_tests.py
1865 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617import pytest1819from selenium.common.exceptions import InvalidElementStateException20from selenium.webdriver.common.by import By212223def test_writable_text_input_should_clear(driver, pages):24pages.load("readOnlyPage.html")25element = driver.find_element(By.ID, "writableTextInput")26element.clear()27assert "" == element.get_attribute("value")282930@pytest.mark.xfail_chrome(reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")31@pytest.mark.xfail_edge(reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")32def test_text_input_should_not_clear_when_disabled(driver, pages):33pages.load("readOnlyPage.html")34element = driver.find_element(By.ID, "textInputNotEnabled")35assert not element.is_enabled()36with pytest.raises(InvalidElementStateException):37element.clear()383940def test_text_input_should_not_clear_when_read_only(driver, pages):41pages.load("readOnlyPage.html")42element = driver.find_element(By.ID, "readOnlyTextInput")43with pytest.raises(InvalidElementStateException):44element.clear()454647def test_writable_text_area_should_clear(driver, pages):48pages.load("readOnlyPage.html")49element = driver.find_element(By.ID, "writableTextArea")50element.clear()51assert "" == element.get_attribute("value")525354@pytest.mark.xfail_chrome(reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")55@pytest.mark.xfail_edge(reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743")56def test_text_area_should_not_clear_when_disabled(driver, pages):57pages.load("readOnlyPage.html")58element = driver.find_element(By.ID, "textAreaNotEnabled")59with pytest.raises(InvalidElementStateException):60element.clear()616263def test_text_area_should_not_clear_when_read_only(driver, pages):64pages.load("readOnlyPage.html")65element = driver.find_element(By.ID, "textAreaReadOnly")66with pytest.raises(InvalidElementStateException):67element.clear()686970def test_content_editable_area_should_clear(driver, pages):71pages.load("readOnlyPage.html")72element = driver.find_element(By.ID, "content-editable")73element.clear()74assert "" == element.text757677