1

All,

We are trying to automate the date picking process for reference Click here! . Please refer date of birth and Appointment date fields. The way we select date is is different. I am not able to get any idea about selecting the dates for both the fields. Could you please help me?

I have tried my best and it's working with below code except date fields

Python version : 2.7 Selenium 3.8.0 Chrome : 48X

    import selenium
    import sys
    from selenium import webdriver
    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.chrome.options import Options
    #profile = webdriver.FirefoxProfile()
    #profile.accept_untrusted_certs = True
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC


    chrome_options = Options()
    chrome_options.add_argument("--disable-extensions")
    driver = webdriver.Chrome(chrome_options=chrome_options)

    driver.get('https://reentryvisa.inis.gov.ie/website/INISOA/IOA.nsf/AppointmentSelection?OpenForm');

    wait = WebDriverWait(driver, 10)
    driver.find_element_by_id('btCom').click()

    username = driver.find_element_by_id('GivenName')
    username.send_keys("First name here ")

    username = driver.find_element_by_id('Surname')
    username.send_keys("Surname here")

    username = driver.find_element_by_id('DOB')
    username.click()            
 ActionChains(driver).move_to_element(username).click().send_keys('01/01/2011').perform()

    username = driver.find_element_by_id('Appdate')
    username.send_keys("12345")

I tried seeing the html for id names etc but I dint find anything specific to year date or month. All I got was below code

    <script src="/website/INISOA/IOA.nsf/bootstrap-datepicker.js"></script>
    <link href="/website/INISOA/IOA.nsf/datepicker3.css" rel="stylesheet">



    <div class="form-group">
    <label class="control-label col-sm-3 col-md-3 col-lg-2" for="DOB">* Date    of Birth:</label>
    <div class="col-sm-3 col-md-3 col-lg-3">
    <div class="input-group date dobdate">

    <input name="DOB" value="" id="DOB" class="form-control readonlywhite"  placeholder="Date of birth" readonly>
    <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
    </div>
    </div>
    </div>

Please help me show away to select the dates in both the fields (Date of birth and Appointment date)

2 Answers2

0

For the date of birth:

dob = driver.find_element_by_id('DOB')    
driver.execute_script("arguments[0].value = arguments[1]", dob, '01/01/2011')

For appointment date:

appdate = driver.find_element_by_id('Appdate')
driver.execute_script("arguments[0].value = arguments[1]", appdate, '12/12/2017')
Marcel
  • 1,443
  • 2
  • 14
  • 24
0

html for date/month/year popup is not under 'DOB input'. you can select the popups using below selectors

datePopup = driver.find_element_by_class('datepicker-days')
monthPopup = driver.find_element_by_class('datepicker-month')
yearPopup = driver.find_element_by_class('datepicker-years')
mahesh
  • 109
  • 1
  • 9