SaeeK
SaeeK

Reputation: 237

Click method not working with Cucumber Phantomjs

Recently i saw 1 wired issue, for a specific CSS, .click method is not working with phantomJS webdriver. It works fine using chrome. I am using below code to click on it by using SITEPRISM .

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

I saw it can click always in chrome and other drivers but not phantomjs. I am using below config for phantomjs:

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

Upvotes: 2

Views: 181

Answers (2)

Saikat...
Saikat...

Reputation: 767

Here's 2 thing 1st you can try:

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

or,

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.

Upvotes: 1

Thomas Walpole
Thomas Walpole

Reputation: 49890

PhantomJS 1.9.x is missing a lot of things modern JS frameworks depend on. The usual cause of JS behavior not happening with PhantomJS, when it works in other browsers, is the lack of Function.prototype.bind . You can polyfill that, but it's really a much better idea to just upgrade your PhantomJS to >= 2.1.x which is more stable and much closer to a modern browser than the 1.9.x releases.

Upvotes: 2

Related Questions