开发者

Capybara + Selenium 2.0 sometimes fails to click on anchor tag

It fails to click on anchor tag <a href="#" onclick="...some js function...;return false;"> (I know <a href="#"> is a bad practice.)

I found some answer on the internet to use fireEvent. But Selenium2.0 does not provide that function anymore, nor Capybara.

Anybody encounters the same problem?

(Now I'm trying Watir-WebDriver, which does not seem to have this problem so far. It is somewhat strange because in wa开发者_JS百科tir-webdriver, it uses selenium-webdriver :S)


Try creating a custom step like the one below and invoke it..

When /^(?:|I )follow javascript anchor "([^"]*)"$/ do |link_selector|
   page.execute_script("$('#{link_selector}').click()")
end


Instead of click, use SendKeys(OpenQA.Selenium.Keys.Enter)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜