Deep Value Deep Value - 7 months ago 8
Python Question

Tab on Website is "Not Clickable" Using Selenium w/ Python

I'm trying to use Selenium to click the tab for quarterly financials on this page:

http://www.msn.com/en-us/money/stockdetails/financials/fi-126.1.AAPL.NAS

When I run my code, it works some of the time, and sometime it tells me:

"Element is not clickable at point (897.7999877929688, 20.100006103515625). Other element would receive the click:

<span class="mectrlname mectrlsignin"></span>"


Here is the code I am running...

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import *
from selenium.webdriver.common.keys import Keys
import time


driver = webdriver.Firefox()
driver.get('http://www.msn.com/en-us/money/stockdetails/financials/fi-126.1.AAPL.NAS')


wait = WebDriverWait(driver, 3)
qtrtab = wait.until(EC.element_to_be_clickable((By.XPATH,'//*[@id="financials-period-list"]/li[2]')))
qtrtab.click()


Does anyone know why sometimes I get the error message and other times it works just fine? Should I be doing this differently? Thanks!

Answer

There is a "frozen" header that covers the element you want to click when the cursor is moved to it. Just maximize the browser window to avoid this problem:

driver = webdriver.Firefox()
driver.maximize_window()
Comments