user6762734
user6762734

Reputation: 13

Python Selenium click on a link in the same tr different td

Hi I would like to click on the Edit Filter button, which appears to be in the same tr for the Fiscal Yr item but in a different td.

enter image description here

This is what I tried:

driver.find_elements_by_xpath("//body//tr[@class='FilterEditCell']/td[2]/a[1]").click()

Could someone please guide me?

Thanks.

Upvotes: 0

Views: 141

Answers (1)

Andersson
Andersson

Reputation: 52665

Try to use below XPath:

//td[contains(., "Fiscal Yr")]/following-sibling::td/a[img[@title="Edit Filter"]]

You might need to use ExplicitWait for dynamic nodes:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC

wait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//td[contains(., "Fiscal Yr")]/following-sibling::td/a[img[@title="Edit Filter"]]'))).click()

Upvotes: 1

Related Questions