-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[py]: remove deprecated
find_element_by_
methods (#10712)
- Loading branch information
Showing
4 changed files
with
1 addition
and
890 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -453,389 +453,6 @@ def title(self) -> str: | |
resp = self.execute(Command.GET_TITLE) | ||
return resp['value'] if resp['value'] else "" | ||
|
||
def find_element_by_id(self, id_) -> WebElement: | ||
"""Finds an element by id. | ||
:Args: | ||
- id\\_ - The id of the element to be found. | ||
:Returns: | ||
- WebElement - the element if it was found | ||
:Raises: | ||
- NoSuchElementException - if the element wasn't found | ||
:Usage: | ||
:: | ||
element = driver.find_element_by_id('foo') | ||
""" | ||
warnings.warn( | ||
"find_element_by_* commands are deprecated. Please use find_element() instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_element(by=By.ID, value=id_) | ||
|
||
def find_elements_by_id(self, id_) -> List[WebElement]: | ||
""" | ||
Finds multiple elements by id. | ||
:Args: | ||
- id\\_ - The id of the elements to be found. | ||
:Returns: | ||
- list of WebElement - a list with elements if any was found. An | ||
empty list if not | ||
:Usage: | ||
:: | ||
elements = driver.find_elements_by_id('foo') | ||
""" | ||
warnings.warn( | ||
"find_elements_by_id is deprecated. Please use find_elements(by=By.ID, value=id_) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_elements(by=By.ID, value=id_) | ||
|
||
def find_element_by_xpath(self, xpath) -> WebElement: | ||
""" | ||
Finds an element by xpath. | ||
:Args: | ||
- xpath - The xpath locator of the element to find. | ||
:Returns: | ||
- WebElement - the element if it was found | ||
:Raises: | ||
- NoSuchElementException - if the element wasn't found | ||
:Usage: | ||
:: | ||
element = driver.find_element_by_xpath('//div/td[1]') | ||
""" | ||
warnings.warn( | ||
"find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_element(by=By.XPATH, value=xpath) | ||
|
||
def find_elements_by_xpath(self, xpath) -> List[WebElement]: | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vvelusamy1
|
||
""" | ||
Finds multiple elements by xpath. | ||
:Args: | ||
- xpath - The xpath locator of the elements to be found. | ||
:Returns: | ||
- list of WebElement - a list with elements if any was found. An | ||
empty list if not | ||
:Usage: | ||
:: | ||
elements = driver.find_elements_by_xpath("//div[contains(@class, 'foo')]") | ||
""" | ||
warnings.warn( | ||
"find_elements_by_xpath is deprecated. Please use find_elements(by=By.XPATH, value=xpath) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_elements(by=By.XPATH, value=xpath) | ||
|
||
def find_element_by_link_text(self, link_text) -> WebElement: | ||
""" | ||
Finds an element by link text. | ||
:Args: | ||
- link_text: The text of the element to be found. | ||
:Returns: | ||
- WebElement - the element if it was found | ||
:Raises: | ||
- NoSuchElementException - if the element wasn't found | ||
:Usage: | ||
:: | ||
element = driver.find_element_by_link_text('Sign In') | ||
""" | ||
warnings.warn( | ||
"find_element_by_link_text is deprecated. Please use find_element(by=By.LINK_TEXT, value=link_text) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_element(by=By.LINK_TEXT, value=link_text) | ||
|
||
def find_elements_by_link_text(self, text) -> List[WebElement]: | ||
""" | ||
Finds elements by link text. | ||
:Args: | ||
- link_text: The text of the elements to be found. | ||
:Returns: | ||
- list of webelement - a list with elements if any was found. an | ||
empty list if not | ||
:Usage: | ||
:: | ||
elements = driver.find_elements_by_link_text('Sign In') | ||
""" | ||
warnings.warn( | ||
"find_elements_by_link_text is deprecated. Please use find_elements(by=By.LINK_TEXT, value=text) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_elements(by=By.LINK_TEXT, value=text) | ||
|
||
def find_element_by_partial_link_text(self, link_text) -> WebElement: | ||
""" | ||
Finds an element by a partial match of its link text. | ||
:Args: | ||
- link_text: The text of the element to partially match on. | ||
:Returns: | ||
- WebElement - the element if it was found | ||
:Raises: | ||
- NoSuchElementException - if the element wasn't found | ||
:Usage: | ||
:: | ||
element = driver.find_element_by_partial_link_text('Sign') | ||
""" | ||
warnings.warn( | ||
"find_element_by_partial_link_text is deprecated. Please use find_element(by=By.PARTIAL_LINK_TEXT, value=link_text) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text) | ||
|
||
def find_elements_by_partial_link_text(self, link_text) -> List[WebElement]: | ||
""" | ||
Finds elements by a partial match of their link text. | ||
:Args: | ||
- link_text: The text of the element to partial match on. | ||
:Returns: | ||
- list of webelement - a list with elements if any was found. an | ||
empty list if not | ||
:Usage: | ||
:: | ||
elements = driver.find_elements_by_partial_link_text('Sign') | ||
""" | ||
warnings.warn( | ||
"find_elements_by_partial_link_text is deprecated. Please use find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text) | ||
|
||
def find_element_by_name(self, name) -> WebElement: | ||
""" | ||
Finds an element by name. | ||
:Args: | ||
- name: The name of the element to find. | ||
:Returns: | ||
- WebElement - the element if it was found | ||
:Raises: | ||
- NoSuchElementException - if the element wasn't found | ||
:Usage: | ||
:: | ||
element = driver.find_element_by_name('foo') | ||
""" | ||
warnings.warn( | ||
"find_element_by_name is deprecated. Please use find_element(by=By.NAME, value=name) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_element(by=By.NAME, value=name) | ||
|
||
def find_elements_by_name(self, name) -> List[WebElement]: | ||
""" | ||
Finds elements by name. | ||
:Args: | ||
- name: The name of the elements to find. | ||
:Returns: | ||
- list of webelement - a list with elements if any was found. an | ||
empty list if not | ||
:Usage: | ||
:: | ||
elements = driver.find_elements_by_name('foo') | ||
""" | ||
warnings.warn( | ||
"find_elements_by_name is deprecated. Please use find_elements(by=By.NAME, value=name)=By.NAME, value=name) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_elements(by=By.NAME, value=name) | ||
|
||
def find_element_by_tag_name(self, name) -> WebElement: | ||
""" | ||
Finds an element by tag name. | ||
:Args: | ||
- name - name of html tag (eg: h1, a, span) | ||
:Returns: | ||
- WebElement - the element if it was found | ||
:Raises: | ||
- NoSuchElementException - if the element wasn't found | ||
:Usage: | ||
:: | ||
element = driver.find_element_by_tag_name('h1') | ||
""" | ||
warnings.warn( | ||
"find_element_by_tag_name is deprecated. Please use find_element(by=By.TAG_NAME, value=name) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_element(by=By.TAG_NAME, value=name) | ||
|
||
def find_elements_by_tag_name(self, name) -> List[WebElement]: | ||
""" | ||
Finds elements by tag name. | ||
:Args: | ||
- name - name of html tag (eg: h1, a, span) | ||
:Returns: | ||
- list of WebElement - a list with elements if any was found. An | ||
empty list if not | ||
:Usage: | ||
:: | ||
elements = driver.find_elements_by_tag_name('h1') | ||
""" | ||
warnings.warn( | ||
"find_elements_by_tag_name is deprecated. Please use find_elements(by=By.TAG_NAME, value=name) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_elements(by=By.TAG_NAME, value=name) | ||
|
||
def find_element_by_class_name(self, name) -> WebElement: | ||
""" | ||
Finds an element by class name. | ||
:Args: | ||
- name: The class name of the element to find. | ||
:Returns: | ||
- WebElement - the element if it was found | ||
:Raises: | ||
- NoSuchElementException - if the element wasn't found | ||
:Usage: | ||
:: | ||
element = driver.find_element_by_class_name('foo') | ||
""" | ||
warnings.warn( | ||
"find_element_by_class_name is deprecated. Please use find_element(by=By.CLASS_NAME, value=name) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_element(by=By.CLASS_NAME, value=name) | ||
|
||
def find_elements_by_class_name(self, name) -> List[WebElement]: | ||
""" | ||
Finds elements by class name. | ||
:Args: | ||
- name: The class name of the elements to find. | ||
:Returns: | ||
- list of WebElement - a list with elements if any was found. An | ||
empty list if not | ||
:Usage: | ||
:: | ||
elements = driver.find_elements_by_class_name('foo') | ||
""" | ||
warnings.warn( | ||
"find_elements_by_class_name is deprecated. Please use find_elements(by=By.CLASS_NAME, value=name) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_elements(by=By.CLASS_NAME, value=name) | ||
|
||
def find_element_by_css_selector(self, css_selector) -> WebElement: | ||
""" | ||
Finds an element by css selector. | ||
:Args: | ||
- css_selector - CSS selector string, ex: 'a.nav#home' | ||
:Returns: | ||
- WebElement - the element if it was found | ||
:Raises: | ||
- NoSuchElementException - if the element wasn't found | ||
:Usage: | ||
:: | ||
element = driver.find_element_by_css_selector('#foo') | ||
""" | ||
warnings.warn( | ||
"find_element_by_css_selector is deprecated. Please use find_element(by=By.CSS_SELECTOR, value=css_selector) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_element(by=By.CSS_SELECTOR, value=css_selector) | ||
|
||
def find_elements_by_css_selector(self, css_selector) -> List[WebElement]: | ||
""" | ||
Finds elements by css selector. | ||
:Args: | ||
- css_selector - CSS selector string, ex: 'a.nav#home' | ||
:Returns: | ||
- list of WebElement - a list with elements if any was found. An | ||
empty list if not | ||
:Usage: | ||
:: | ||
elements = driver.find_elements_by_css_selector('.foo') | ||
""" | ||
warnings.warn( | ||
"find_elements_by_css_selector is deprecated. Please use find_elements(by=By.CSS_SELECTOR, value=css_selector) instead", | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
return self.find_elements(by=By.CSS_SELECTOR, value=css_selector) | ||
|
||
def pin_script(self, script, script_key=None) -> ScriptKey: | ||
""" | ||
|
Oops, something went wrong.
this is impacting seleniumlibrary versions used in https://github.com/robotframework/SeleniumLibrary . Since this is removed, what else is the alternative method.