Calendar conditional date clicks are failing

use(TimeCategory, {

    today = new Date()

})

def checkoutmonth = (today + 10).format(‘MM’)

print(('checkout month is ’ + checkoutmonth) + ‘\n’)

def checkoutday = (today + 30).format(‘d’)

print(('checkout day is ’ + checkoutday) + ‘\n’)

def currentmonth = (today).format(‘MM’)

print(('Current month is ’ + currentmonth) + ‘\n’)

WebUI.openBrowser(GlobalVariable.G_SiteURL)

WebUI.waitForPageLoad(3)

WebUI.maximizeWindow()

WebUI.waitForElementVisible(findTestObject(‘Object Repository/Web_OR/Landing_page/search_textbox’), 5)

WebUI.setText(findTestObject(‘Object Repository/Web_OR/Landing_page/search_textbox’), 'Boston ')

WebUI.delay(3)

WebUI.click(findTestObject(‘Object Repository/Web_OR/Search_Parking_Landing/google_menu_landing_result1’))

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/date_filter’))

WebUI.delay(2)

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/checkout_date’))

TestObject to = WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/date_select’),

'xpath', 'equals', ('//div\[@id="parking-list-checkIn"\]/multiple-date-picker//div\[@class="picker-days-row"\]//span\[text()=' + 

checkoutday) + '\]', true)

if (checkoutmonth == currentmonth) {

WebUI.click(to)

}

else {

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/next_month’))

WebUI.click(to)

}

Exception Getting:

Test Cases/Helper/New Test Case FAILED because (of) Unable to click on object ‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/date_select’ (Root cause: org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (280, 225). Other element would receive the click:

(Session info: chrome=67.0.3396.99)

(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 0 milliseconds

Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’

System info: host: ‘HPUSER-PC’, ip: ‘192.168.0.115’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_102’

Driver info: com.kms.katalon.selenium.driver.CChromeDriver

Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.35.528161 (5b82f2d2aae0ca…, userDataDir: C:\Users\HPUSER~1\AppData\L…}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 67.0.3396.99, webStorageEnabled: true}

Session ID: 83831ada311699521ac5bafea24f8118)

WebUI.focus(findTestObject('Object Repository/input_date_filter'))WebUI.executeJavaScript('$(\':input\').removeAttr(\'readonly\')', [])WebUI.delay(1)WebUI.setText(findTestObject('Object Repository/input_date_filter'), '2022-01-01')

you can copy this script and try to run it. Perhaps, the script is readonly so you couldn’t click or send keys. You need to remove the readonly first then set text.

Thanks @ratri - was not able to make the above code work, but i have fixed by myself

WebUI.openBrowser(GlobalVariable.G_SiteURL)

WebUI.waitForPageLoad(3)

use(TimeCategory, {

today = new Date() })

String checkindate = (today+17).format(‘MMMM yyyy’)

String checkinday = (today+17).format(‘d’)

String checkoutdate = (today+24).format(‘MMMM yyyy’)

String checkoutday = (today+24).format(‘d’)

print(checkindate +"\t")

print(checkoutdate +"\t")

print(“Today’s date is " +checkinday +”\t")

print(“Today’s date is " +checkoutday +”\t")

WebUI.maximizeWindow()

WebUI.waitForElementVisible(findTestObject(‘Object Repository/Web_OR/Landing_page/search_textbox’), 5)

WebUI.setText(findTestObject(‘Object Repository/Web_OR/Landing_page/search_textbox’), 'Boston ')

WebUI.delay(2)

WebUI.click(findTestObject(‘Object Repository/Web_OR/Search_Parking_Landing/google_menu_landing_result1’))

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/date_filter’))

// Selecting CheckIn date

WebDriver driver = DriverFactory.getWebDriver()

String cin_date_text = driver.findElement(By.xpath("//*[@class=‘text-center picker-month ng-binding’]")).getText()

println (cin_date_text)

if (checkindate == cin_date_text)

{

TestObject from = WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/date_select’), ‘xpath’, ‘equals’, ‘//div[@id=“parking-list-checkIn”]/multiple-date-picker//div[@class=“picker-days-row”]//span[text()=’+checkinday+’]’, true)

WebUI.click(from, FailureHandling.CONTINUE_ON_FAILURE)

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/applytosave’))

}

else

{

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/next_month’))

TestObject n_from = WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/date_select’), ‘xpath’, ‘equals’, ‘//div[@id=“parking-list-checkIn”]/multiple-date-picker//div[@class=“picker-days-row”]//span[text()=’+checkinday+’]’, true)

WebUI.click(n_from, FailureHandling.CONTINUE_ON_FAILURE)

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/applytosave’))

}

WebUI.delay(2)

// Selecting CheckOut date

driver = DriverFactory.getWebDriver()

// Need to click twise as the first click only highlights and second click do actual click

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/checkout_date’))

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/checkout_date’))

WebUI.delay(2)

String cout_date_text = driver.findElement(By.xpath("//*[@class=‘text-center picker-month ng-binding’]")).getText()

println (cout_date_text)

if (checkoutdate == cout_date_text)

{

TestObject to = WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/date_select’), ‘xpath’, ‘equals’, ‘//div[@id=“parking-list-checkIn”]/multiple-date-picker//div[@class=“picker-days-row”]//span[text()=’+checkoutday+’]’, true)

WebUI.click(to, FailureHandling.CONTINUE_ON_FAILURE)

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/applytosave’))

}

else

{

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/next_month’))

TestObject n_to = WebUI.modifyObjectProperty(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/date_select’), ‘xpath’, ‘equals’, ‘//div[@id=“parking-list-checkIn”]/multiple-date-picker//div[@class=“picker-days-row”]//span[text()=’+checkoutday+’]’, true)

WebUI.click(n_to, FailureHandling.CONTINUE_ON_FAILURE)

WebUI.click(findTestObject(‘Object Repository/Web_OR/Parking_Results_Page/Date_Selection/applytosave’))

}

driver.quit();