Issue
I'm using Selenium to scrape a Web Page and I'm having some problems targeting some attributes.
The page I'm trying to scrape looks like this:
<div>
<span abc> content </span>
<span def> content2 </span>
<div>
My goal would be to retrieve the text within the "span abc" tag, without selecting the other text included in the "span def" tag.
I've tried multiple approaches and looked at a lot of different resources but I wasn't able to find the right approach, since I don't want to select all the spans at the same time and I don't want to search based on the text within the tags.
Solution
A simple approach would be indexing cause you do not want to select based on
since I don't want to select all the spans at the same time and I don't want to search based on the text within the tags.
If abc is an attribute please use :
//div/span[@abc]
or
with indexing :
(//div/span[@abc])[1]
Answered By - cruisepandey
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.