How can I find and click elements in my calendar?

I need more of that source code to help you. Can you attach the entire html source code

Thank you very much for the response.
Yess, my mistake…it should be like this:
String num1 = number1.toString()
String num2 = number2.toString()

I dont really understand what you are trying to tell me (sorry) but whenever I do that in the console of the browser it does something like this:
orange

Perfect. It proves you can target the cell you highlighted here:

I suspect the thing you want to click on is inside that td-element. Open it and post a screenshot.

Now try this in the browser console:

document.querySelector("div#schedulerSch .k-scheduler-content>table td:nth-child(5) > span").click()

When you have proved that works, then you can place it in your Test Case. Your code above uses j as a cell index so something like this:

for (int j = 0; j < Cols.size(); j++) {
  if(...) {
    String js = '''
    document.querySelector("div#schedulerSch .k-scheduler-content>table td:nth-child(${j}) > span").click()
    '''
    WebUI.executeJavaScript(js, null)
    ...

For background on using CSS and JS in Groovy/TestCases:

Thanks once again for the response.
When I do that in the console it does not work. The thing is that I need to double click if not I would do something like Cols.get(j).click

Solved !
This line was wrong:
String objectXpathV = CustomKeywords.‘keywordPrueba.CustomFunction.createIdRelative’(’////div[@id=‘schedulerSch’]/table/tbody/tr[2]/td/div/table/tbody/tr[’, i,j)

It should be like this:
CustomKeywords.‘keywordPrueba.CustomFunction.createIdRelative’(’//div[@id=‘schedulerSch’]/table/tbody/tr[2]/td/div/table/tbody/tr[’, i,j)

1 Like

There is a plugin dedicated for Calendar, could this make your life easier in the future?

https://store.katalon.com/product/25/Calendar-Keywords

Thanks for the answer. I am not really sure if that plugin does what I need to do.

This is the code that I have right now

WebDriver driver = DriverFactory.getWebDriver()

WebElement Table = driver.findElement(By.className('k-scheduler-content'))

List<WebElement> Rows = Table.findElements(By.tagName('tr'))

println('Rows: ' + Rows.size())

println('Rows: ' + Rows.get(0).getText())

Date today = new Date()

String todaysDate = today.format('mm/dd/yy').substring(3, 5)
println(todaysDate + " ")
for (int i = 0; i < Rows.size(); i++) {
	List<WebElement> Cols = Rows.get(i).findElements(By.tagName('td'))

	for (int j = 0; j < Cols.size(); j++) {
		if (Cols.get(j).getText().equals(todaysDate)) {
			println(i + " " + j + " ")
			TestObject toV = new TestObject()
			
			String objectXpathV = CustomKeywords.'keywordPrueba.CustomFunction.createIdRelative'('//div[@id=\'schedulerSch\']/table/tbody/tr[2]/td/div/table/tbody/tr[',
				i + 1, j + 1)

			toV.addProperty('xpath', ConditionType.EQUALS, objectXpathV)

			WebUI.waitForElementPresent(toV, 30)

			WebUI.delay(3)

			WebUI.doubleClick(toV)
		}
	}
}

It works but it does nothing. The frame that should appear whenever I clic toV does not appear

For some reason it only lets mi click if I refresh the page

hello you,

why you are not using query selector as Russ ping here

For the same reason I wrote in a previous comment. That solution was not working and what I need is a double click not a single click

hello,

check this
https://www.guru99.com/double-click-and-right-click-selenium.html

1 Like

Thanks a lot for the answer.
My solution or yours do not work, because in a certain point the page refreshes and it stops me from clicking no matter what method I use.
Why it does it? I do not know because this was not happening yesterday

hello you,

i guess that page will refresh cause there is done database read or write query (back end), not sure but this is my strong guess

Its a strange thing because I sometimes notice the page refreshes and sometimes I do not. In any of this cases, I cannot click. I will keep on searching what the problem is and let you know if I can solve it.

Wow, look what I found. Whenever I run the tc, the calendar gets broken.

All you need is a JavaScript dblclick function. Go find one. Use it in your code instead of my .click() call.

You seem to be focusing on everything that shows no sign of being close to working instead of focusing on code that’s pretty darn close. You already have code that targets the cell you want - we proved it by making it orange. Now go find a dblclick function and use it.

You can lead a horse to water…