2
selenium.click([xpath to object])

Selenium click method seems to be screwed up for me. It recognises the button I want to click and thinks it clicks it. But nothing happens on the screen. The next line involves clicking another button on the next screen. It fails because it cant locate the button because the first click hasn't actually happened.

[EDIT] It looks like It just fails to click after the screen changes. It will click the log in button fine, and load the new screen. The next click fails, but if i give it a gentle push(IE click the button for it) all the followin clicks in the script run fine. So it seems to be a problem with a click after a screen change?

confusified
  • 2,320
  • 7
  • 22
  • 29
  • It would be helpful to see the code for the button and the code/locator you are using to perform the click. – highlycaffeinated Jun 01 '11 at 16:28
  • did you figure out what was wrong, without clicking it yourself? – oma Aug 09 '11 at 11:00
  • @oma, It seems in the end it was just an error with loading. I added a delay and all was right with the world once again :) – confusified Aug 17 '11 at 11:07
  • ok, thx! btw the source of my problem was mootools js lib. It's wasn't best friends with selenium. http://stackoverflow.com/q/6996141/252799 – oma Aug 17 '11 at 12:51

3 Answers3

1

you can try this:

WebElement element = driver.findElement(By.id("button"));    
JavascriptExecutor executor = (JavascriptExecutor)driver;    
executor.executeScript("arguments[0].click();", element);
Thirumalai murugan
  • 5,698
  • 8
  • 32
  • 54
Praveen
  • 378
  • 3
  • 6
  • Since you are not able to use selenium click method you can try to click on the button by using javascript – Praveen Jun 19 '14 at 06:18
1

I had a similar problem and this code worked for me:

    mouseOver(locator);
    mouseDownAt(locator, "10,10");
    mouseUpAt(locator, "10,10");

I wrapped it up in a clickButton() method and use it instead of click()

Mark Pope
  • 11,244
  • 10
  • 49
  • 59
0

If you're doing it on Internet Explorer, there is a known bug that its window must be foremost. Some people get past this with doing another event which makes the window get focus like clicking twice or maximising, etc. etc.

Mike Kwan
  • 24,123
  • 12
  • 63
  • 96