0

I'm trying to make fill a feedback form ( actually it is attendance ) automatically with python. I'm able to traverse through all the pages but every page has different value and id for "Present" it is kind of dynamic

Is there a way I can find "Present" radio button on the page. I don't have much knowledge of html

snippets of the website

P.S. I've read the question on stackoverflow already but the answer were not able to solve it will still give me error

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

2

This xpath should find your input tag based off the Present tag.

//span[text()='Present']/preceding::input

By it's class

//input[class='form-check-input ']
Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32
0

To click on the element with text as Present you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following based Locator Strategies:

  • Using index:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='statusdesc' and text()='Present']//preceding::input[1]"))).click()
    
  • Using attributes:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='statusdesc' and text()='Present']//preceding::input[@class='form-check-input ' and @name='status']"))).click()
    
  • Note: You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352