Home > Net >  Finding XPATH for an DOB
Finding XPATH for an DOB

Time:03-17

I am not able to locate the xpath for the DOB field for the following page as the right click is disabled in the DOB calendar. Any leads will be helpful.

For example, I am trying to select the DOB as 1st Mar,2004

https://pos-diy.iiflinsurance.com/form/proposer-form?quote_id=dARV3Hz22VvXFwtRy5Ev

CodePudding user response:

You don't really need to click on the Calendar and then Select a date.

You can parse the value using execute_script

Code:

driver.get("https://pos-diy.iiflinsurance.com/form/proposer-form?quote_id=dARV3Hz22VvXFwtRy5Ev")

wait = WebDriverWait(driver, 30)
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input[placeholder='Full Name']"))).send_keys('Apratim Chaudhuri')
dob = wait.until(EC.visibility_of_element_located((By.XPATH, "//input[@type='date']")))

driver.execute_script("arguments[0].value = arguments[1]", dob, "2004-03-01")

Imports:

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

CodePudding user response:

This XPath expression will match:

"//input[@formcontrolname='dob']"

Or even this

"//input[@formcontrolname]"
  • Related