laurentj / slimerjs

A scriptable browser like PhantomJS, based on Firefox
http://slimerjs.org
Other
3k stars 258 forks source link

Selenium webdriver using Slimerjs fails to execute "find_element" and similiar methods #630

Open MarcoG3 opened 7 years ago

MarcoG3 commented 7 years ago

versions

Steps to reproduce the issue

driver = webdriver.PhantomJS(executable_path="/path/to/slimerjs_bin")
driver.get('https://google.com')
driver.find_element('asd')

Actual results:

selenium.common.exceptions.WebDriverException: Message: Error - Unable to load Atom 'find_element' from file 'undefined/third_party/webdriver-atoms/find_element.js'

Causes

It looks like the problem is in vendors/ghostdriver/webdriver_atoms.js at line 32:

var atomFileName = module.dirname + "/third_party/webdriver-atoms/" + atomName + ".js";

here, module.dirname is undefined when driver.find_element is executed.

if I hardcode the path it works perfectly. Anyone could take a look at how to solve that for everyone, avoiding full paths? I'd be happy to make a PR.