Reputation: 390
I got some problems with selenium on python.
Currently, I am using driver.find_elements_by_xpath("//a[@href]")
to get all web elements with an href. However, there are some hrefs with target=“_blank”, cousing selenum to open a new tab, which I dont want.
Is it possible to filter out those elements somehow?
Upvotes: 0
Views: 48
Reputation: 1556
You can try to filter them out by modifying your xpath, this should make it:
driver.find_elements_by_xpath("//a[@href and not(@target='_blank')]")
Good luck!
Upvotes: 1