I am creating a selenium test and in all the tests I want to simulate the user choosing the date. The problem is when the month changes the possible date selections is limited making it very fragile.
This is my current code:
sel.click("fromdate")
sel.click("//div[@id='dp-popup']/div[3]/table/tbody/tr[2]/td[6]")
sel.click("//div[@id='dp-popup']/div[3]/table/tbody/tr[3]/td[1]")
Is there a way to get around this either creating a function that determines the correct cell to choose or if I should just inject the value into the field ?
I’m using selenium and jQuery date picker. I’m always using xpath checker in selenium tests to create stable tests.
Well, this is the path of month name
//html/body/div[@id='ui-datepicker-div']/div/div/span[1]and this gives the year//html/body/div[@id='ui-datepicker-div']/div/div/span[2]and this is//html/body/div[@id='ui-datepicker-div']/table/tbody/tr[**week index of month.you can think this is a row in datepicker**]/td[**column index of a datepicker.you can think this is a day of a week**]Try to use xpath checker to get locators.
Hope this helps.