Answer the question
In order to leave comments, you need to log in
Why won't browsers start with selenium nodejs?
Why might this code not work? 2 drivers are in the same folder. But nothing happens at node index, after a minute the error is Timed out waiting for the WebDriver server at 127.0.0.1:52408/. I tried to run the driver myself, but nothing helps. Chrome driver of that version, checked
//index.js
const {Builder, By, Key, until} = require('selenium-webdriver');
async function example() {
try{
let driver = await new Builder().forBrowser('firefox').build();
await driver.get('http://www.google.com/ncr');
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
} catch (err){
console.log(err)
}
};
example()
Answer the question
In order to leave comments, you need to log in
It is necessary to launch selenium itself separately.
1. download wget selenium-release.storage.googleapis.com/3.9/seleni...
2. run java -jar selenium-server-standalone-3.9.1.jar
3. use
const { Builder, By, Key, until } = require('selenium-webdriver');
(async function example() {
let driver = await new Builder().forBrowser('firefox').usingServer('http://localhost:4444/wd/hub').build();
try {
await driver.get('http://www.google.com/ncr');
await driver.findElement(By.name('q')).sendKeys('webdriver', Key.RETURN);
await driver.wait(until.titleIs('webdriver - Google Search'), 1000);
} finally {
await driver.quit();
}
})();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question