Answer the question
In order to leave comments, you need to log in
How to fix phantomjs error in node.js?
When trying to run a script that uses selenium webdriver and phantomjs, it gives the following error:
TypeError: webdriver.Capabilities.phantomjs is not a function
at Object. (C:\Users\Administrator\WebstormProjects\project\test.js:8:46)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal /modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node. js:266:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
const webdriver = require('selenium-webdriver');
const by = webdriver.By;
var browser = new webdriver
.Builder()
.withCapabilities(webdriver.Capabilities.phantomjs())
.build();
browser.manage().window().setSize(800, 600);
browser.get('https://instagram.com/login');
browser.sleep(20000);
browser.findElement(by.xpath('//*[@id="root"]/div/div[2]/div[1]/form/div[1]/label/input')).sendKeys('login');
browser.findElement(by.xpath('//*[@id="root"]/div/div[2]/div[1]/div/form/div[2]/label/input')).sendKeys('password');
browser.findElement(by.xpath('//*[@id="root"]/div/div[2]/div[1]/div/form/div[4]/button[1]/span/span')).click();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question