简体   繁体   中英

Problem " driver.find_element_by_xpath("//div[@class='example']"

I have been experiencing this problem for a few days. I use Pycharm and Python:

UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead")

Regards

Try the following...

First, import By as follows: from selenium.webdriver.common.by import By

Then if you're trying to find an element by xpath, for example, replace:

find_elements_by_xpath("[***whatever the xpath is***]")

with:

driver.find_element(By.XPATH, "[***whatever the xpath is***]")

For examples of the various ways to call elements refer to this reference website for Selenium with Python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM