【Python】seleniumで取得した要素をクリックできないときの対処法

driver.find_element_by_xpath('xpath').click()

 

上記のように、seleniumで取得した要素をクリックするコードを実行すると、

以下のようなエラーとなってしまうことがある。

 

selenium.common.exceptions.WebDriverException: Message: unknown error: Element is not clickable at point (486, 1564)

 

必ずしもクリックをする必要がなく、リンク先に飛べればいい場合は、

要素のhref属性を利用することで解決できた。

 

url = driver.find_element_by_xpath('xpath').get_attribute('href')
driver.get(url)