Hey there. I am having some trouble using Chrome Remote Interface on top of Chromedriver. I use Chromedriver to start chrome, find the remote-debugging-port and then connect Chrome Remote Interface to this port. Although the connection is successful, subsequent commands do not (i.e client.Page.navigate()) produce any effect. I understand Chrome can be started with chrome-launcher but I would like to use Webdriver to simulate certain workflows
Here is a test script to reproduce the issue(Given chromedriver is installed):
//test.js
var webdriver = require("selenium-webdriver");
var chrome = require("selenium-webdriver/chrome");
var cdp = require("chrome-remote-interface");
async function test(){
var options = new chrome.Options();
options.addArguments(["--detach=true"]);
//START DRIVER
var driver = new webdriver.Builder().
withCapabilities(options.toCapabilities()).build();
//FIND REMOTE DEBUGGING PORT
await driver.get("chrome://version");
let element = await driver.findElement(webdriver.By.id('command_line'));
let text = await element.getText();
console.log('Chrome command line flags:');
console.log(text);
var splitStr=text.split(" ");
let port = 0;
splitStr.filter(function(word,index){
if(word.match(/--remote-debugging-port=*/)){
console.log(word);
port = Number(word.split('=')[1]);
}else{
}
});
console.log(typeof port)
console.log('Port:');
console.log(port);
//START CHROME REMOTE INTERFACE
cdp({
port:port
}, function(chrome){
console.log(chrome);
chrome.Page.enable();
chrome.Page.navigate({'url': 'https://yahoo.com'}) //NOT WORKING
}).on('error', function (e) {
console.error('Cannot connect to Chrome', e);
});
}
test();
SELENIUM_BROWSER=chrome node test.js
This script works when Chrome is started via chrome-launcher, so my guess is starting Chrome via chromedriver may have options enabled that impede Chrome Remote interface to work on top of it.
Hey there. I am having some trouble using Chrome Remote Interface on top of Chromedriver. I use Chromedriver to start chrome, find the remote-debugging-port and then connect Chrome Remote Interface to this port. Although the connection is successful, subsequent commands do not (i.e client.Page.navigate()) produce any effect. I understand Chrome can be started with chrome-launcher but I would like to use Webdriver to simulate certain workflows
Here is a test script to reproduce the issue(Given chromedriver is installed):
SELENIUM_BROWSER=chrome node test.js
This script works when Chrome is started via chrome-launcher, so my guess is starting Chrome via chromedriver may have options enabled that impede Chrome Remote interface to work on top of it.