Path: blob/trunk/py/test/selenium/webdriver/common/element_equality_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.1617from selenium.webdriver.common.by import By181920def test_same_element_looked_up_different_ways_should_be_equal(driver, pages):21pages.load("simpleTest.html")22body = driver.find_element(By.TAG_NAME, "body")23xbody = driver.find_elements(By.XPATH, "//body")[0]2425assert body == xbody262728def test_different_elements_are_not_equal(driver, pages):29pages.load("simpleTest.html")30body = driver.find_element(By.TAG_NAME, "body")31div = driver.find_element(By.TAG_NAME, "div")3233assert body != div343536def test_same_elements_found_different_ways_should_not_be_duplicated_in_aset(driver, pages):37pages.load("simpleTest.html")38body = driver.find_element(By.TAG_NAME, "body")39xbody = driver.find_elements(By.XPATH, "//body")40s = set(xbody)41s.add(body)42assert 1 == len(s)434445