简体   繁体   中英

Selenium find all custom named tags

How can I find all custom HTML tags named job-title-text and it's value(s) Sr Manager using Selenium in Python? The tag appears multiple times with different values throughout my HTML.

Here's how my HTML looks like:

<a ph-tevent="job_click" ref="linkEle" href.bind="getUrl(linkEle, 'job', eachJob, '', eachJob.jobUrl)" data-ph-at-id="job-link" data-ph-id="ph-page-element-page20-CRUCUZ" job-title-text="Sr Manager" data-ph-at-job-post-date-text="2021-11-23T00:00:00.000Z">

This will give you all web elements containing job-title-text attribute

all_elements = driver.find_elements_by_xpath("//*[@job-title-text]")

This will give you all web elements containing job-title-text attribute with value equals to Sr Manager

all_elements = driver.find_elements_by_xpath("//*[@job-title-text='Sr Manager']")

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