How to send Date from Source Input text file into combo box Calendar Date Picker

Hi

I need to know how to set Date into combo box Calendar Date Picker field from Source Input text file.

Iam using application build on .jnlp file (swing based application components) and using RobotFramework along with RemoteSwing Library.

Scenario Details :- We have source file which has Date which on basis of meeting IF condition will then set this Date field dropdown/combo box with this source date.

Since, this dropdown/combobox is a Calendar Date Picker field rather than just a textbox it is becoming difficult to set the source date value in it. Any suggestions ?

Hi @robouser ,

Some of the date pickers, you can ignore the calendar picker and just overwrite the date, if that works it’s usually the easiest way.

Otherwise , you’ll need to break up the date into parts, and use those parts to manipulate the calendar picker (in a web page these will show up inside a dynamic element often a div)

If you don’t want add a seperate library for breaking up the dates it’s easy to do with the python split and the builtin Evalutate keyword like this:

	${year} 	${month} 	${day}= 	Evaluate    "2024-02-29".split("-")
	${day} 	${month} 	${year}= 	Evaluate    "29/02/2024".split("/")

Can you please elaborate with an example in this doubt context? sorry I was not able to understand.
even if its able to split date by’-’ or ‘/’ but how it will set the date combo box field?

Iam not able to update the Image here otherwise it would be helpful to visualize what combobox Iam talking about.

As explained, this app is a .jnlp app not browser so finding out the components/elements their xpath, css etc are not available. We are using remoteswinglibrary with roboframework.

So, this is a dropdown (remoteswinglibrary directs to use combobox for dropdown). When you click to extend this it shows calendar picker to select the required date. I have a date in the source file which is stored in some Variable name. So, If somehow if my code is able to take the variable name then it would work. But, for some reason, its not taking it. Below is what I tried unsuccessfully :-

Select From Combo Box 0 ${datevaluefrmsourcefile}
Type Into Combobox 0 ${datevaluefrmsourcefile}

Hi @robouser

I Haven’t tested a .jnlp app before, so on that side i’ll have to let someone else answer what the keywords you need are, I’m guessing your using one of the java libraries (swing?), so below i’ll put <JavaLibrary>, replace this with whichever library you are using

I’ve given you an example below with a web datepicker, I know it’s not going to be the same, but the concepts should be.

What I expect you’ll need to do:

  • Replace the Load JQuery Theme Page keyword in my example with the navigation to your datepicker (you should already have this)
  • Replace the selenium keyword Get Text with the <JavaLibrary> equivalent keyword
  • Replace the selenium keyword Click Link with the <JavaLibrary> equivalent keyword

After that you should be able to just re-use my keywords and have a working example :crossed_fingers:t2:

Dave.

*** Settings ***
Library 	SeleniumLibrary
Library 	Collections

*** Test Cases ***

JQuery Datepicker Date In Past
	Load JQuery Theme Page
	Select Date From DatePicker 	2020-01-01
	Close Browser

JQuery Datepicker Date In Future
	Load JQuery Theme Page
	Select Date From DatePicker 	2024-02-29
	Close Browser

*** Keywords ***
Load JQuery Theme Page
	Open Browser 	https://jqueryui.com/themeroller/	Chrome
	Scroll Element Into View	id:datepicker
	Scroll Element Into View	id:progressbar
	# Capture Page Screenshot

Select Date From DatePicker
	[Arguments] 	${NewDate}
	${NewYear} 	${NewMonth} 	${NewDay}= 	Evaluate    "${NewDate}".split("-")
	${NewMonth}= 	Convert To Integer    ${NewMonth}
	${NewDay}= 	Convert To Integer    ${NewDay}
	Wait Until Keyword Succeeds    1 min	100ms 	Move DatePicker To Year 	${NewYear}
	Wait Until Keyword Succeeds    1 min	100ms 	Move DatePicker To Month 	${NewMonth}
	Click Link    //div[@id="datepicker"]//a[@data-date="${NewDay}"]
	Capture Page Screenshot

Move DatePicker To Year
	[Arguments] 	${NewYear}
	# Capture Page Screenshot
	${CurrYear}= 	DatePicker Current Year
	Run Keyword If 	${NewYear}>${CurrYear} 	DatePicker Click Next Month
	Run Keyword If 	${NewYear}<${CurrYear} 	DatePicker Click Prev Month
	${CurrYear}= 	DatePicker Current Year
	Should Be Equal As Numbers 	${CurrYear} 	${NewYear}
	# Capture Page Screenshot

Move DatePicker To Month
	[Arguments] 	${NewMonth}
	# Capture Page Screenshot
	${CurrMonth}= 	DatePicker Current Month
	Run Keyword If 	${NewMonth}>${CurrMonth} 	DatePicker Click Next Month
	Run Keyword If 	${NewMonth}<${CurrMonth} 	DatePicker Click Prev Month
	${CurrMonth}= 	DatePicker Current Month
	Should Be Equal As Numbers 	${CurrMonth} 	${NewMonth}
	# Capture Page Screenshot


DatePicker Current Year
	# 	//div[@id="datepicker"]//span[@class="ui-datepicker-year"]		# Year
	${DPYear}=	Get Text 	//div[@id="datepicker"]//span[@class="ui-datepicker-year"]
	[Return]	${DPYear}

DatePicker Current Month
	# 	//div[@id="datepicker"]//span[@class="ui-datepicker-month"]		# Month
	@{Months}= 		Create List 	0thMonth 	January 	February	March	April	May	June	July	August	September	October	November	December
	${DPMonth}= 	Get Text 	//div[@id="datepicker"]//span[@class="ui-datepicker-month"]
	${DPNumMonth}= 	Get Index From List 	${Months} 	${DPMonth}
	[Return]	${DPNumMonth}


DatePicker Click Prev Month
	Click Link    //div[@id="datepicker"]//a[@title="Prev"] 	# Prev Month

DatePicker Click Next Month
	Click Link	//div[@id="datepicker"]//a[@title="Next"]	# Next Month

Hi Dave

It didnt work for me.
Actually, as said, we are using remoteswinglibrary and Application is JLNP file (kind of windows based).
So, we do not have a way to get the Element attribute details.
Thats why Iam kind of stuck here. I also thought of using JSExecutor but again I need Element, Driver details to get this work.

Thanks