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
@hrefattribute off.Use
.//div[@id='containeriso3']/div/a[1]Then use
get_attributeto get thehreffrom it.