Reputation: 2330
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?
Upvotes: 2
Views: 1217
Reputation: 387
you can try this:
WebElement element = driver.findElement(By.id("button"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
Upvotes: 1
Reputation: 24447
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.
Upvotes: 0
Reputation: 11264
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()
Upvotes: 1