Feature request: support phantomjs-prebuilt in selenium-webdriver
See original GitHub issueMeta -
OS: Win32
Selenium Version: 2.53.2
Browser: phantomjs, which installed by npm install phantomjs-prebuilt
Browser Version: 2.1.7
Expected Behavior -
npm install selenium-webdriver
npm install phantomjs-prebuilt
node js source
const driver = new WebDriver.Builder()
.withCapabilities(
WebDriver.Capabilities.phantomjs()
).build()
should find phantomjs executable, and return success.
Actual Behavior -
cant find phantomjs executable.
test\node_modules\selenium-webdriver\phantomjs.js:80
throw Error(
^
Error: The PhantomJS executable could not be found on the current PATH. Please download the latest version from http://phantomjs.org/download.html and ensure it can be found on your PATH. For more information, see https://github.com/ariya/phantomjs/wiki
at Error (native)
...
Steps to reproduce -
step 1. open cmd window step 2. run
mkdir test
cd test
npm install selenium-webdriver
npm install phantomjs-prebuilt
step 3. then run this node js source
const WebDriver = require('selenium-webdriver')
const driver = new WebDriver.Builder()
.withCapabilities(
WebDriver.Capabilities.phantomjs()
).build()
step 4. webdriver said that cant find phantomjs executable.
Steps to quick fix -
step 1. find executable installed by phatomjs-prebuilt in node_modules.bin
D:\test>dir node_modules\.bin\phantomjs*
node_modules\.bin 的目录
2016/05/09 11:59 335 phantomjs
2016/05/09 11:59 212 phantomjs.cmd
step 2. reason: in selenium-webdriver/phantomjs.js:
const PHANTOMJS_EXE =
process.platform === 'win32' ? 'phantomjs.exe' : 'phantomjs';
it only find .exe . but the phantomjs-prebuilt installed executable name is .cmd
step 3. fix: add .cmd
to search io.findPath
:
function findExecutable(opt_exe) {
const PHANTOMJS_CMD = 'phantomjs.cmd'
var exe = opt_exe || io.findInPath(PHANTOMJS_EXE, true) || io.findInPath(PHANTOMJS_CMD, true);
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Feature request: support phantomjs-prebuilt in selenium-webdriver
Feature request : support phantomjs-prebuilt in selenium-webdriver. ... Selenium Version: 2.53.2. Browser: phantomjs, which installed by npm install ...
Read more >Is there a way to use PhantomJS in Python? - Stack Overflow
The easiest way to use PhantomJS in python is via Selenium. The simplest installation method is. Install NodeJS; Using Node's package manager install ......
Read more >mocha vs phantomjs-prebuilt vs puppeteer vs selenium-webdriver ...
Finally, come chat with the maintainers on Gitter if you want to help with: Triaging issues, answering questions; Review, merging, and closing pull...
Read more >PhantomJS - Scriptable Headless Browser
PhantomJS is a headless web browser scriptable with JavaScript. It runs on Windows, macOS, Linux, and FreeBSD. Using QtWebKit as the back-end, it...
Read more >phantomjs-prebuilt | Yarn - Package Manager
An NPM installer for PhantomJS, headless webkit with JS API. Build Status. Building and Installing. npm install phantomjs-prebuilt. Or grab the ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Happened to be working with this issue and found that you can technically get around this by building a PhantomJS driver around a custom Capability linking to the location of the executable.
You just write something like this in the beginning of your own test, no need to modify selenium’s code:
Since Selenium provides instructions for how to work with a custom Firefox install, I wrote instructions for how to use phantomjs-prebuilt with selenium-webdriver here
Marking this as a feature request as we’ve never claimed to support phantomjs-prebuilt. I will not accept a PR that introduces a dependency on that module, but would consider a PR that made selenium-webdriver aware of it when searching for the executable.