From 8b2bab56187b026efa5b91dda1a3d4e06f36c451 Mon Sep 17 00:00:00 2001 From: AutomatedTester Date: Tue, 10 Mar 2020 11:41:55 +0000 Subject: [PATCH] [py] Deprecate find_element(s)_by_* calls --- py/selenium/webdriver/remote/webdriver.py | 16 ++++++++++++++++ py/selenium/webdriver/remote/webelement.py | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/py/selenium/webdriver/remote/webdriver.py b/py/selenium/webdriver/remote/webdriver.py index 10ce7d067604f..73f09b1cdeb76 100644 --- a/py/selenium/webdriver/remote/webdriver.py +++ b/py/selenium/webdriver/remote/webdriver.py @@ -378,6 +378,7 @@ def find_element_by_id(self, id_): element = driver.find_element_by_id('foo') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.ID, value=id_) def find_elements_by_id(self, id_): @@ -396,6 +397,7 @@ def find_elements_by_id(self, id_): elements = driver.find_elements_by_id('foo') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.ID, value=id_) def find_element_by_xpath(self, xpath): @@ -416,6 +418,7 @@ def find_element_by_xpath(self, xpath): element = driver.find_element_by_xpath('//div/td[1]') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.XPATH, value=xpath) def find_elements_by_xpath(self, xpath): @@ -434,6 +437,7 @@ def find_elements_by_xpath(self, xpath): elements = driver.find_elements_by_xpath("//div[contains(@class, 'foo')]") """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.XPATH, value=xpath) def find_element_by_link_text(self, link_text): @@ -454,6 +458,7 @@ def find_element_by_link_text(self, link_text): element = driver.find_element_by_link_text('Sign In') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.LINK_TEXT, value=link_text) def find_elements_by_link_text(self, text): @@ -472,6 +477,7 @@ def find_elements_by_link_text(self, text): elements = driver.find_elements_by_link_text('Sign In') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.LINK_TEXT, value=text) def find_element_by_partial_link_text(self, link_text): @@ -492,6 +498,7 @@ def find_element_by_partial_link_text(self, link_text): element = driver.find_element_by_partial_link_text('Sign') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text) def find_elements_by_partial_link_text(self, link_text): @@ -510,6 +517,7 @@ def find_elements_by_partial_link_text(self, link_text): elements = driver.find_elements_by_partial_link_text('Sign') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text) def find_element_by_name(self, name): @@ -530,6 +538,7 @@ def find_element_by_name(self, name): element = driver.find_element_by_name('foo') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.NAME, value=name) def find_elements_by_name(self, name): @@ -548,6 +557,7 @@ def find_elements_by_name(self, name): elements = driver.find_elements_by_name('foo') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.NAME, value=name) def find_element_by_tag_name(self, name): @@ -568,6 +578,7 @@ def find_element_by_tag_name(self, name): element = driver.find_element_by_tag_name('h1') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.TAG_NAME, value=name) def find_elements_by_tag_name(self, name): @@ -586,6 +597,7 @@ def find_elements_by_tag_name(self, name): elements = driver.find_elements_by_tag_name('h1') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.TAG_NAME, value=name) def find_element_by_class_name(self, name): @@ -606,6 +618,7 @@ def find_element_by_class_name(self, name): element = driver.find_element_by_class_name('foo') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.CLASS_NAME, value=name) def find_elements_by_class_name(self, name): @@ -624,6 +637,7 @@ def find_elements_by_class_name(self, name): elements = driver.find_elements_by_class_name('foo') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.CLASS_NAME, value=name) def find_element_by_css_selector(self, css_selector): @@ -644,6 +658,7 @@ def find_element_by_css_selector(self, css_selector): element = driver.find_element_by_css_selector('#foo') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.CSS_SELECTOR, value=css_selector) def find_elements_by_css_selector(self, css_selector): @@ -662,6 +677,7 @@ def find_elements_by_css_selector(self, css_selector): elements = driver.find_elements_by_css_selector('.foo') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.CSS_SELECTOR, value=css_selector) def execute_script(self, script, *args): diff --git a/py/selenium/webdriver/remote/webelement.py b/py/selenium/webdriver/remote/webelement.py index 8f29b846ccd11..09e49689c0d92 100644 --- a/py/selenium/webdriver/remote/webelement.py +++ b/py/selenium/webdriver/remote/webelement.py @@ -181,6 +181,7 @@ def find_element_by_id(self, id_): foo_element = element.find_element_by_id('foo') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.ID, value=id_) def find_elements_by_id(self, id_): @@ -199,6 +200,7 @@ def find_elements_by_id(self, id_): elements = element.find_elements_by_id('foo') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.ID, value=id_) def find_element_by_name(self, name): @@ -218,6 +220,7 @@ def find_element_by_name(self, name): element = element.find_element_by_name('foo') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.NAME, value=name) def find_elements_by_name(self, name): @@ -235,6 +238,7 @@ def find_elements_by_name(self, name): elements = element.find_elements_by_name('foo') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.NAME, value=name) def find_element_by_link_text(self, link_text): @@ -254,6 +258,7 @@ def find_element_by_link_text(self, link_text): element = element.find_element_by_link_text('Sign In') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.LINK_TEXT, value=link_text) def find_elements_by_link_text(self, link_text): @@ -271,6 +276,7 @@ def find_elements_by_link_text(self, link_text): elements = element.find_elements_by_link_text('Sign In') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.LINK_TEXT, value=link_text) def find_element_by_partial_link_text(self, link_text): @@ -290,6 +296,7 @@ def find_element_by_partial_link_text(self, link_text): element = element.find_element_by_partial_link_text('Sign') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text) def find_elements_by_partial_link_text(self, link_text): @@ -307,6 +314,7 @@ def find_elements_by_partial_link_text(self, link_text): elements = element.find_elements_by_partial_link_text('Sign') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text) def find_element_by_tag_name(self, name): @@ -326,6 +334,7 @@ def find_element_by_tag_name(self, name): element = element.find_element_by_tag_name('h1') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.TAG_NAME, value=name) def find_elements_by_tag_name(self, name): @@ -343,6 +352,7 @@ def find_elements_by_tag_name(self, name): elements = element.find_elements_by_tag_name('h1') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.TAG_NAME, value=name) def find_element_by_xpath(self, xpath): @@ -376,6 +386,7 @@ def find_element_by_xpath(self, xpath): element = element.find_element_by_xpath('//div/td[1]') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.XPATH, value=xpath) def find_elements_by_xpath(self, xpath): @@ -408,6 +419,7 @@ def find_elements_by_xpath(self, xpath): elements = element.find_elements_by_xpath("//div[contains(@class, 'foo')]") """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.XPATH, value=xpath) def find_element_by_class_name(self, name): @@ -427,6 +439,7 @@ def find_element_by_class_name(self, name): element = element.find_element_by_class_name('foo') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.CLASS_NAME, value=name) def find_elements_by_class_name(self, name): @@ -444,6 +457,7 @@ def find_elements_by_class_name(self, name): elements = element.find_elements_by_class_name('foo') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.CLASS_NAME, value=name) def find_element_by_css_selector(self, css_selector): @@ -463,6 +477,7 @@ def find_element_by_css_selector(self, css_selector): element = element.find_element_by_css_selector('#foo') """ + warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead") return self.find_element(by=By.CSS_SELECTOR, value=css_selector) def find_elements_by_css_selector(self, css_selector): @@ -480,6 +495,7 @@ def find_elements_by_css_selector(self, css_selector): elements = element.find_elements_by_css_selector('.foo') """ + warnings.warn("find_elements_by_* commands are deprecated. Please use find_elements() instead") return self.find_elements(by=By.CSS_SELECTOR, value=css_selector) def send_keys(self, *value):