charlietaylor
charlietaylor

Reputation: 153

undefined method `execute_script' in page object gem

I have started to get this error when running my tests using the 1.2.2 version of the page object gem

Stacktrace

undefined method `execute_script' for <Selenium::WebDriver::Firefox::Bridge:0x00000003cbdba0> (NoMethodError)

/usr/lib64/ruby/gems/2.2.0/gems/page-object-1.2.2/lib/page-object/platforms/selenium_webdriver/element.rb:146:in `parent'

/usr/lib64/ruby/gems/2.2.0/gems/page-object-1.2.2/lib/page-object/platforms/selenium_webdriver/table_row.rb:30:in `find_index_by_title'

/usr/lib64/ruby/gems/2.2.0/gems/page-object-1.2.2/lib/page-object/platforms/selenium_webdriver/table_row.rb:15:in `[]'

It occurs when trying to get the value from a table using a method such as

left_table_element[rank][column]

NB. This had been previously working for over a year so I wonder if a new issue has been introduced?

Looking at the git blame it does seem like the line of code throwing the error in the element.rb might have been changed recently and maybe caused this regression?

Upvotes: 0

Views: 1066

Answers (2)

Anil
Anil

Reputation: 21

To fix this issue just need to update your page-object gem to 1.2.2 version

gem install -v 1.2.2 (for selenium-webdriver 3.x only)

Upvotes: 0

Justin Ko
Justin Ko

Reputation: 46846

The problem is due a change in Selenium-WebDriver. In version 3.0.0, the Remote::Bridge#executeScript method was renamed to #execute_script.

The Page-Object gem was updated in version 1.2.2 to use the new method. However, the gem dependencies were not updated to reflect the required version - ie Selenium-WebDriver v2.53.4 is still listed as the minimum requirement. It looks like this has already been fixed in the eventual Page-Object v2.0 release.

In the meantime, you can fix the issue by upgrading to Selenium-WebDriver v3 (assuming you do not want to downgrade Page-Object):

gem install selenium-webdriver

Upvotes: 1

Related Questions