I have an xpath which works in python-scrapy and also in the firebug extension of firefox. But, it is not working in python-selenium. The code I am using in selenium is this
xpath = ".//div[@id='containeriso3']/div/a[1]/@href"
browser.find_element_by_xpath(xpath)
This gives an InvalidSelectorException error. Does selenium use some other xpath version?
That isn't going to get you an element. You need to take the @href
attribute off.
Use .//div[@id='containeriso3']/div/a[1]
Then use get_attribute
to get the href
from it.
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.