简体   繁体   中英

How can I select an element with a specific `title` using selenium in python

How can I get an item with a specific attribute using selenium and click on it? In my case one with a title of "Store Type". I've tried XPath and many other ways, but still can't do this.

The following is an example image depicting the problem

页面标记

You can get element by xpath:

//div[@title="Store Type"]

If I'm not mistaken in python is:

driver.find_element_by_xpath('//div[@title="Store Type"]').click()

You can click on the element using xpath:

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@title='Store Type']"))).click()

Note: You have to add the following imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

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