Python Selenium Path not found

I have wrote the code

import os
from import ChromeDriverManager
import time

from selenium import webdriver
from import Options
from selenium.webdriver.common.keys import Keys
from import By
from import WebDriverWait
from import expected_conditions as EC

options = Options()
options.page_load_strategy = 'eager'
driver = webdriver.Chrome(options=options)
url = ""
    wait = WebDriverWait(driver, 10)
except Exception:
driver.send_keys(Keys.CONTROL +'Escape')
    wait = WebDriverWait(driver, 5)
except Exception:
    driver.send_keys(Keys.CONTROL +'Escape')
for i in range(0, 50):
    bonus_month = driver.find_element_by_xpath ("//*[@class= 'mctable1.thborder.frtab']/tbody/tr[%s]/td[1]"%(i)) 
    bonus = driver.find_element_by_xpath ("//*[@class= 'mctable1.thborder.frtab']/tbody/tr[%s]/td[1]"%(i)) 

This gives me error

no such element: Unable to locate element: {"method":"xpath","selector":"//*[@class= 'mctable1.thborder.frtab']/tbody/tr[0]/td[1]"}

Element on the page: enter image description here

Where I am making mistake in finding Exbonus and Ratio?


First use the clickable method from the expected conditions to check that the element is clickable within given time to just make sure it is operational.

Once the click action performed on the bonus link the table takes some time to finishes loading. In meantime selenium tries to fetch the table content and fails to get it. So again add wait for the element to load and then grab the table using Xpath and iterate over the rows of the table. –

WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//ul[@id='corporation_tab']//a[@href='#ca_bonus']")))


WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//tbody[@id='id_b']/tr")))

tableRows = driver.find_elements_by_xpath('//tbody[@id="id_b"]/tr')
for i in tableRows:
    AnnouncementDate = i.find_element_by_xpath('td[1]').text
    exbonus = i.find_element_by_xpath('td[2]').text
    ratio = i.find_element_by_xpath('td[3]').text

    print(AnnouncementDate + " tt " + exbonus + " tt " + ratio)

This returns me the output –

enter image description here

You will need following extra import –

from import expected_conditions as EC