开发者

Selenium fails to click

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 开发者_如何学Pythonthe 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?


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()


you can try this:

WebElement element = driver.findElement(By.id("button"));    
JavascriptExecutor executor = (JavascriptExecutor)driver;    
executor.executeScript("arguments[0].click();", element);


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜