Skip to content

Conversation

symonk
Copy link
Member

@symonk symonk commented May 29, 2022

I think this is alright for 4.3 now. Removal of find_element_by_ methods throughout the python bindings. I don't think any tests where running through those but instead the correct find_element|find_elements. Will grab fallout from CI if any occurs.

Likely some docs related fallout here, will address as I find it.

@codecov-commenter
Copy link

Codecov Report

Merging #10712 (51c8d61) into trunk (fe6bc99) will increase coverage by 0.71%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##            trunk   #10712      +/-   ##
==========================================
+ Coverage   46.64%   47.36%   +0.71%     
==========================================
  Files          86       86              
  Lines        5855     5572     -283     
  Branches      278      278              
==========================================
- Hits         2731     2639      -92     
+ Misses       2846     2655     -191     
  Partials      278      278              
Impacted Files Coverage Δ
py/selenium/webdriver/remote/webdriver.py 37.28% <ø> (-4.62%) ⬇️
py/selenium/webdriver/remote/webelement.py 34.44% <ø> (+1.48%) ⬆️
...lenium/webdriver/support/event_firing_webdriver.py 18.18% <ø> (+7.63%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe6bc99...51c8d61. Read the comment docs.

@symonk symonk added this to the 4.3 milestone May 29, 2022
@symonk symonk added the C-py Python Bindings label May 29, 2022
@Ahsoka
Copy link

Ahsoka commented Aug 23, 2022

Hello,
I was wondering why these methods were removed.
Thank you!

@titusfortner
Copy link
Member

@Ahsoka #8806 (comment)

@Pikamander2
Copy link

Pikamander2 commented Sep 22, 2022

For anyone who's in the process of updating their code, here are 16 find-and-replace strings that you can use:

.find_element_by_class_name(
.find_element(By.CLASS_NAME, 

.find_element_by_css_selector(
.find_element(By.CSS_SELECTOR, 

.find_element_by_id(
.find_element(By.ID, 

.find_element_by_link_text(
.find_element(By.LINK_TEXT, 

.find_element_by_name(
.find_element(By.NAME, 

.find_element_by_partial_link_text(
.find_element(By.PARTIAL_LINK_TEXT, 

.find_element_by_tag_name(
.find_element(By.TAG_NAME, 

.find_element_by_xpath(
.find_element(By.XPATH, 

.find_elements_by_class_name(
.find_elements(By.CLASS_NAME, 

.find_elements_by_css_selector(
.find_elements(By.CSS_SELECTOR, 

.find_elements_by_id(
.find_elements(By.ID, 

.find_elements_by_link_text(
.find_elements(By.LINK_TEXT, 

.find_elements_by_name(
.find_elements(By.NAME, 

.find_elements_by_partial_link_text(
.find_elements(By.PARTIAL_LINK_TEXT, 

.find_elements_by_tag_name(
.find_elements(By.TAG_NAME, 

.find_elements_by_xpath(
.find_elements(By.XPATH, 

You'll also need to import By if you haven't already done so:

from selenium.webdriver.common.by import By

evansd added a commit to bennettoxford/openprescribing that referenced this pull request Dec 5, 2022
These are supported in Selenium 3 but become mandatory in Selenium 4.

Helpful translation table:
SeleniumHQ/selenium#10712 (comment)
@grepwood
Copy link

I'm joining @Ahsoka. @symonk why was this removed? We would like to know the full story, because I as a selenium user honestly don't see any benefit, in fact, I had to commit spare time to rewrite my code. Time I could otherwise spend drinking beer and eating curry.

@titusfortner
Copy link
Member

It's a more maintainable API and more consistent with what the other implementations are doing.

There's a lot of code in this repo to keep on top of, and we also like to have time to drink beer and eat curry.

@symonk symonk deleted the remove-find-element-by-methods branch December 10, 2022 18:40
@grepwood
Copy link

@titusfortner that's a perfectly understandable explanation. Thank you! Enjoy your beer and curry :)

garoxas added a commit to garoxas/Scweet that referenced this pull request Dec 11, 2022
Remove deprecated find_element_by_* and find_elements_by_* (SeleniumHQ/selenium#10712)
Save images using original filename
longavailable added a commit to longavailable/practices that referenced this pull request May 19, 2023
- Deprecated find_element_by_ methods in SeleniumHQ/selenium#10712

- DeprecationWarning: executable_path has been deprecated, please pass in a Service object in SeleniumHQ/selenium#9995

- Instead default chromedriver by [undetected-chromedriver](https://pypi.org/project/undetected-chromedriver, to fix https://stackoverflow.com/questions/59515561/this-browser-or-app-may-not-be-secure-error-while-attempting-to-login-in-to-gm
lhelwerd added a commit to grip-on-software/visualization-site that referenced this pull request Jun 1, 2023
- Upgrade Python to 3.9 now that cffi provides musllinux packages
- Upgrade Selenium standalone Chrome to 4.8.1 for newer ESM support
- Run tests in verbose mode and update one Selenium import
- Update find_elements?_by_.*(...) calls to find_elements?(By..., ...)
  since SeleniumHQ/selenium#10712
- Close driver during teardown even when there is no result outcome, to
  avoid keeping connections open for too long
- Add remote connection timeout to detect connection issues earlier per
  SeleniumHQ/selenium#11596
- Remove some Python 2 import attempt
- Axe report: Do not exit out if file does not exist
- Adjust move_to_element_with_offset calls to work in center element,
  based on SeleniumHQ/selenium#11402
- Quit driver and set to None at teardown. This should properly close
  the session, allowing the connection to be reused for another test.
- Update browser-sync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-py Python Bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants