10

The application that am working on was recently revamped and as part of that a new JQuery calendar was introduced. I need to click on a link in the calendar to select the time and date. However, Selenium.click is not working. The command gets executed, but nothing happens on the screen.

To check whether my XPATH/CSS locator (I tried both) is correct, I added selenium.getText(locator) and selenium.highlight(locator) commands. Both worked!. No issues in that. Its ONLY the click that is not working.

Upon checking in firebug, I could see that the div on which I am trying to click is kind of grayed out state. Does it meant that element is disabled? See the screenshot of the firebug below.

I also tried to run the same command in Selenium IDE. In IDE this works "sometimes".

I am running this test using Selenium 1.xx.

I did one more thing as part of debugging. During the test run, I opened the Selenium IDE in the browser so that it records what actions are happening. IDE recorded all actions till this click. But I couldn't see anything in the IDE when the click command was executed. Any idea guys, what would be cause?

Has anyone faced a similar issue before? Any help would be appreciated!!!

EDIT Added screenshot of the calendar. The calendar comes up like a popup on top of the existing window. enter image description here

enter image description here

asked May 27, 2011 at 5:55
5
  • Have you tried the clickAt(0,0) function? That helps in a lot of cases. Commented May 27, 2011 at 6:24
  • I tried, but would like to confirm whether that is the correct way. Here is what i tried selenium.clickAt("locator",""); Is this correct? Commented May 27, 2011 at 6:35
  • Nope. That should be selenium.clickAt("locator","0,0"); Commented May 27, 2011 at 8:08
  • I would not suggest using clickAt, as it gets highly dependent on pixel level info on a page. Commented May 27, 2011 at 8:51
  • Oh.OK. Anyways, clickAt too didn't work. Commented May 27, 2011 at 9:20

6 Answers 6

3

Try clicking the element through Action class.

WebElement webElement = driver.findElement(By.id("Your ID Here"));
Actions builder = new Actions(driver);
builder.moveToElement(webElement).click(webElement);
builder.perform();

If clicking with action class does not work, you can also try clicking element by Javascript.

WebElement webElement = driver.findElement(By.id("Your ID here"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", webElement);
answered Oct 27, 2015 at 6:21
2

Though you would be missing testing calendar functionality but if nothing works (as it is not just clicking calendar link but you would also have to navigate to right place in calendar) and it becomes a blocker then try typing directly in text box.

answered May 27, 2011 at 8:54
3
  • Guess what, there is no text box :). Selecting is the ONLY way. Commented May 27, 2011 at 9:19
  • so I assume u make a selection and date appears like text label on page, any way I could access ur app or any similar application on net? Commented May 27, 2011 at 11:36
  • Application is currently internal. I can post some screenshots though. Commented May 27, 2011 at 11:41
1

This is a little bit of a long shot, but since this thread doesn't seem to be going anywhere... Usually, when Selenium has problems clicking on things in IE it is because the Zoom Level is not at 100%.

answered Jun 10, 2011 at 13:16
1

I could not get click or clickAndWait to work on a cell in a grid that was generated using EXT.NET too. I was sure that the locator was working because pressing the Find button in the Selenium IDE caused the cell to be briefly highlighted in yellow. I finally tried clickAt and it worked. Here's what I specified:

Command: clickAt
Target: //*[@id='ext-gen336']/div[3]/table/tbody/tr/td[4]/
Value: 0,0

The syntax for clickAt is given as clickAt(locator, coordString). The x,y values for coordString don't seem to matter so I simply used 0,0.

answered May 16, 2012 at 12:16
0

Can you have a try with selenium.mouseDown(TargetLocator)?

Now TargetLocator can be till the immediate before div of the span OR till the span.

Please try with both.

answered Jun 29, 2012 at 14:56
0

if click command in selenium does not work, then follow the below steps :

Method-1 : driver.findElement(By.name("submit")).sendKeys(Keys.RETURN);

Method-2 : driver.findElement(By.name("submit")).sendKeys(Keys.ENTER);

Reference : Click command in selenium webdriver

answered Sep 12, 2018 at 18:01
1
  • 1
    Please do not post answers that reference your article a) without attribution, and b) by quoting with no indication what you are quoting. See sqa.stackexchange.com/help/promotion for more information. Commented Sep 12, 2018 at 19:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.