emiley Posted May 23, 2022 Share Posted May 23, 2022 I am using autoIt to handle the saveAs dialog box in selenium java. Here, I should save the pdf file in required directory ControlFocus("Save As","","Edit1") ControlSend("Save As","","Edit1","-----My file path\file_name.pdf") ControlClick("Save As","","Button2") Is it possible to add today's date or last weekend date(Saturday) in my file name and send in the file path to get saved? Link to comment Share on other sites More sharing options...
Musashi Posted May 23, 2022 Share Posted May 23, 2022 23 minutes ago, emiley said: Is it possible to add today's date ... in my file name and send in the file path to get saved? [NOT TESTED] Local $sFilepath = "-----My file path\file_name" & "-" & @YEAR & "-" & @Mon & "-" & @MDAY & ".pdf" ControlFocus("Save As","","Edit1") ControlSend("Save As","","Edit1",$sFilepath) ControlClick("Save As","","Button2") "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
emiley Posted May 23, 2022 Author Share Posted May 23, 2022 30 minutes ago, Musashi said: [NOT TESTED] Local $sFilepath = "-----My file path\file_name" & "-" & @YEAR & "-" & @Mon & "-" & @MDAY & ".pdf" ControlFocus("Save As","","Edit1") ControlSend("Save As","","Edit1",$sFilepath) ControlClick("Save As","","Button2") Thanks, it added today's date in my file name! But, I am still trying to figure out how to add last weekend (saturday) date here. Link to comment Share on other sites More sharing options...
Musashi Posted May 23, 2022 Share Posted May 23, 2022 2 hours ago, emiley said: Thanks, it added today's date in my file name! But, I am still trying to figure out how to add last weekend (saturday) date here. Try this : #include <Date.au3> Local $sFilepath, $sCurrentDate, $aYMD, $iWeekday, $sDateLastSaturday $sCurrentDate = _NowCalcDate() $aYMD = StringSplit($sCurrentDate, "/", 2) $iWeekday = _DateToDayOfWeek($aYMD[0], $aYMD[1], $aYMD[2]) $sDateLastSaturday = _DateAdd("D", - $iWeekday, $sCurrentDate) $sFilepath = "-----My file path\file_name" & "-" & StringReplace($sDateLastSaturday, "/", "-") & ".pdf" ControlFocus("Save As","","Edit1") ControlSend("Save As","","Edit1",$sFilepath) ControlClick("Save As","","Button2") "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now