I am trying enter today's date into a date picker field rather than just click the today
button and below is how my code is set up, but not able to do so. I am using BDD framework.
And I input todays date
@When('I input todays date')
def step_impl(context):
value_paystub_dateOfPayStub(context.webdriver)
Getting element of said date picker:
def get_dateOfPaystub(driver):
element = None
try:
element = WebDriverWait(driver, 70).until(
EC.visibility_of_element_located(
(By.XPATH, "//input[@id='chl.CustomerFinancials.primaryFinancialsForm.paystub.6134.DateOfPaystub']"))
)
except TimeoutException:
logger.error("Date of Paystub element was not found")
return element
Trying to enter today's date:
def value_paystub_dateOfPayStub(driver):
currentdate = datetime.datetime.today()
try:
element = get_dateOfPaystub(driver)
element.send_keys() # to set focus on the selector
element.send_keys(currentdate, "%m-%d-%Y")
except Exception:
logger.error("Unable to enter value into Paystub Employer Name field")
Any help would be appreciated.