单击方法不适用于 Cucumber Phantomjs

Click method not working with Cucumber Phantomjs

最近我看到 1 个有线问题,对于特定 CSS,.click 方法不适用于 phantomJS webdriver。使用 chrome 效果很好。我正在使用以下代码通过 SITEPRISM 单击它。

@page = someclass.new
@page.wait_for_fld_element_rows(30)
@page.fld_element_rows.first.click

我看到它在 chrome 和其他驱动程序中总是可以点击,但不是 phantomjs。我正在为 phantomjs 使用以下配置:

Capybara::Selenium::Driver.new(app, :browser => :phantomjs,     
desired_capabilities: { 'phantomjs.cli.args' => ['--ignore-ssl-errors=yes'] 

PhantomJS 1.9.x 缺少很多现代 JS 框架所依赖的东西。当 PhantomJS 在其他浏览器中工作时,JS 行为没有发生的通常原因是缺少 Function.prototype.bind 。你可以填充它,但是将你的 PhantomJS 升级到 >= 2.1.x 确实是一个更好的主意,它比 1.9.x 版本更稳定,更接近现代浏览器。

这是您可以尝试的第一件事:

1st) You can upgrade to phantomjs 2.1.1 (latest) as this is more stable version. 

或者,

2nd) Not-clicking Issue might happenned because of the ajax req. You can use retry with in rescue block and try to click again which may solve this issue.