简体   繁体   English

在 Python selenium 中定位元素

[英]Locating a element in Python selenium

I'm writing a script in python and I'm having a problem locating an element in this website: https://www.charika.ma/societe-rechercher .我正在用 python 编写脚本,但在此网站中定位元素时遇到问题: https : //www.charika.ma/societe-rechercher

I want to pass to the middle: div class="col-md-7 col-sm-7 middle-side".我想传递到中间:div class="col-md-7 col-sm-7 middle-side"。 to extract the information in the middle.提取中间的信息。 I'm using this script :我正在使用这个脚本:

try:
row = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.XPATH, "col-md-7 col-sm-7 middle-side"))
)
print(row.text)

except:
    driver.quit()

The best way would be to find element by class looks like "middle-side" is enough to go of.最好的方法是按类查找元素,看起来“中间”就足够了。 Have you tried?你有没有尝试过?

a = driver.find_elements_by_class_name("middle-side")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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