Reputation: 184
I'm trying to use selenium with python for parsing page. I have a HTML page with this markup:
<body>
<div my-id="article-3">some text</div>
<div my-id="article-4">some text1</div>
</body>
And I need to specify not only the value, but also the name:
divs = driver.find_element_by_id('article-3')
Because my-id="article-3"
is not id="article-3"
.
How to set custom id?
Upvotes: 1
Views: 592
Reputation: 2015
You can use the CSS selector.
div = driver.find_element_by_css_locator('div[my-id="article-3"]')
Upvotes: 4