-1
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, 15).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'td:nth-child(2)>input')))
driver.find_element(By.CSS_SELECTOR, 'td:nth-child(2)>input').send_keys(element[0])

The portion HTML script with CSS searched of the website the portion HTML script with CSS searched of the website

Both codes are not working. Format looks correct.

Maybe CSS Selector seems to be the problem?

The ID attribute changes every time when there is a different input prior to this page

Code raising a TimeoutExceptionError

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • there's an ID attribute there... I'd use that to locate as it should be unique. Ex: xpath of: //input[@id='t_306'] – pcalkins Jun 17 '22 at 17:38

1 Answers1

0

Syntactically the css_selector:

td:nth-child(2)>input

is correct but still have a logical error.

Though the above css_selector indicates immediate <input> descendant of second <td> child, but of whom? In this case you have to provide a reference node uniquely identified by locator strategy first.

As an example:

  • With respect to <table> tag:

    table td:nth-child(2) > input
    
  • With respect to <tbody class="z-row"> tag:

    tbody.z-row td:nth-child(2) > input
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352