Closed rahul-sr closed 7 years ago
This seems to work for me locally:
const { Chrome } = require('../build');
const chrome = new Chrome();
let tab = {};
chrome
.start()
.then((instance) => {
tab = instance;
return tab.navigate('https://www.google.com/');
})
.then(() => {
return tab.screenshot('/Users/jgriffith/Downloads/google.png')
})
.then(() => {
return tab.done()
});
What version of navalia are you using (or did are you on master)?
I should also note that I'll have a larger change coming out soon that will dispose of the start
command and make setup much easier, especially when using just the Chrome
module
Thanks @joelgriffith for quick response. I used version 0.0.9 . Also I tried after cloning the master and the above example as you mentioned. Still facing the same issue.
Error: unexpected server response (500)
at ClientRequest._req.on (/Documents/navalia/node_modules/chrome-remote-interface/node_modules/ws/lib/WebSocket.js:651:26)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:191:7)
at HTTPParser.parserOnIncomingClient (_http_client.js:522:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
at Socket.socketOnData (_http_client.js:411:20)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:178:18)
at Socket.Readable.push (_stream_readable.js:136:10)
at TCP.onread (net.js:561:20)
ReferenceError: tab is not defined
This is the exact error log.
"chrome-remote-interface" is having version : "0.23.3"
It could have to do with the Chrome version difference (I'm using Canary). Try these steps:
feature/docs-no-startup
npm run build
Create this file in the root of the repo (temp.js):
const { Chrome } = require(./build');
const chrome = new Chrome();
chrome.goto('https://www.chromestatus.com/')
.then(() => chrome.screenshot('/Users/jgriffith/Downloads/chromestatus.png')) // Change this filepath for you
.then(() => chrome.done());
Run it with: DEBUG=navalia:chrome node temp.js
@joelgriffith Yes the above solution works, even without the first step (Chrome Canary). Thanks.
Awesome, going to close
Getting this error : Unhandled promise rejection (rejection id: 1): Error: unexpected server response (500) and sometimes Error: 'Target.createBrowserContext' wasn't found
Using Chrome Version 59.0.3071.115
Just tried this example:
Also tried other examples , getting the same 500 error. A quick help would be appreciable.