Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJonathan Grieve
Treehouse Moderator 91,253 PointsSelenium - Windows 10
Okay, I'm going to get to the bottom of this and I'm going to feel like the king of the world when I do :)
As you know, I'm on Windows 10 Home. I'm using JavaScript to try and run Selenium.
- npm Version 5.5.1
- node Version 8.4.0
- ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f)
If I try to run the following from the file...
//require modules for Selenium and ChromeDriver
const selenium = require("selenium-webdriver");
//require chromedriver
require("chromedriver");
//define connection to chromedriver
const driver = new selenium.Builder().forBrowser("chrome").build();
//store URL to retrieve via driver.get();
const url = "https://www.jonniegrieve.co.uk";
//open chrome instance to URL
driver.get(url);
/*environment variable access
```driver.get(process.env.URL);```
export URL=https://www.jonniegrieve.co.uk*/
... a chrome instance will open, run any test it's been told to do and then close. This is the Iog I keep getting.
[1020/102030.334:ERROR:process_reader_win.cc(123)] NtOpenThread: {Access Denied} A process has requested access to an object, but has not been granted those access rights. (0xc0000022)
[1020/102030.336:ERROR:exception_snapshot_win.cc(87)] thread ID 688 not found in process
[1020/102030.336:WARNING:crash_report_exception_handler.cc(62)] ProcessSnapshotWin::Initialize failed
[1020/102953.113:ERROR:process_reader_win.cc(151)] SuspendThread: Access is denied. (0x5)
I think I've narrowed it down to a user priveleges error in Windows but I've tried scouring the internet for people who have been in a similar situation there's not a lot out there.
5 Answers
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsHey Jonathan,
I ran the code from your index.js in my REPL and it works. Here is my output. I am on Windows 10.
I am obviously not running any tests, but you can debug this further by commenting out your tests until you find the line of code causing this.
> const selenium = require("selenium-webdriver");
undefined
> const driver = new selenium.Builder().forBrowser("chrome").build();
undefined
> const url = "https://www.jonniegrieve.co.uk";
undefined
> driver.get(url)
ManagedPromise {
flow_:
ControlFlow {
propagateUnhandledRejections_: true,
activeQueue_:
TaskQueue {
name_: 'TaskQueue::15',
flow_: [Circular],
tasks_: [Object],
interrupts_: null,
pending_: null,
subQ_: null,
state_: 'new',
unhandledRejections_: Set {} },
taskQueues_: Set { [Object] },
shutdownTask_: null,
hold_:
Timeout {
_called: false,
_idleTimeout: 2147483647,
_idlePrev: [Object],
_idleNext: [Object],
_idleStart: 32807,
_onTimeout: [Function],
_timerArgs: undefined,
_repeat: 2147483647,
domain: [Object] } },
stack_:
{ Task: WebDriver.navigate().to(https://www.jonniegrieve.co.uk)
at thenableWebDriverProxy.schedule (C:\Users\Skykomish\Documents\WebPage\selenium\node_modules\seleniu
m-webdriver\lib\webdriver.js:807:17)
at Navigation.to (C:\Users\Skykomish\Documents\WebPage\selenium\node_modules\selenium-webdriver\lib\we
bdriver.js:1131:25)
at thenableWebDriverProxy.get (C:\Users\Skykomish\Documents\WebPage\selenium\node_modules\selenium-web
driver\lib\webdriver.js:988:28)
at repl:1:8
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:73:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:340:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12) name: 'Task' },
parent_: null,
callbacks_: null,
state_: 'pending',
handled_: false,
value_: undefined,
queue_: null }
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsI tried the same code previously run in my REPL in an index.js file and it works fine for me. I am not seeing anything different.
Jonathan Grieve
Treehouse Moderator 91,253 PointsCan I just ask, what's your variation of Windows 10.... is it Win 10 Home? 64bit? Thanks :)
Jonathan Grieve
Treehouse Moderator 91,253 PointsDale, it's just occured to me you were talking about running tests directly from REPL. My tests from REPL work 100%
But it's when I open through node index
to run the JavaScript file that I get outputs to the log and the browser closes. Was this the same for you?
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsWindows 10 Home 64-bit
Jonathan Grieve
Treehouse Moderator 91,253 PointsThen I really am at a complete loss as to what is happening.
I'll try another post on the Selenium user group. I'm determined to get to the bottom of this but the answer doesn't seem to be out there.
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsIt works for me running node index.js
. Here is my index.js file:
//require modules for Selenium and ChromeDriver
const selenium = require("selenium-webdriver");
//define connection to chromedriver
const driver = new selenium.Builder().forBrowser("chrome").build();
//store URL to retrieve via driver.get();
const url = "https://www.jonniegrieve.co.uk";
//open chrome instance to URL
driver.get(url);
Jonathan Grieve
Treehouse Moderator 91,253 PointsThanks for your reply. I just replaced my code yours. But still closes the browser after downloading all the assets.
Back to the drawing board I go :)
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 PointsOK good luck. I don't know why that would be happening only with running Node.
Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 PointsThanks Dale.
I can confirm that although I'm not doing any actual tests myself it works for me when I put the commands through REPL.
What I actually managed to do when I tried to do
node index
was to download chrome driver for 2.33 as directed in the error message in REPL which is when it started to work flawlessly in REPL. I'm even able to skip the require("chromedriver"); command.This chromedriver (2.33) seems to be the one I need for REPL but unfortunately it's still closing the driver when I run
node index
. This is using all the same commands as I do in REPL. All very strange.Jonathan Grieve
Treehouse Moderator 91,253 PointsJonathan Grieve
Treehouse Moderator 91,253 PointsThere's nothing wrong with the code, I'm convinced of that. It opens and runs the test but then closes as soon as the page is finished downloading assets.
I think the problem is an access rights issue, maybe a hardware issue. If I could just work out where to look I might be able to get to the bottom of it....