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 trial
Jonathan GrieveTreehouse Moderator 91,252 Points
Environment Variable not working
This a trifle bit annoying :)
So I'm trying to set up the workspace URL as the URL set to the environment variable. I'm on Windows 10 so I do this as directed in the teachers notes :)
Then all that's left to do is copy the shared code into my Git Bash to see if it'll pick up the URL.
It doesn't actually do this. It'll simply open a blank instance of Chrome.
const selenium = require("selenium-webdriver");
const By = selenium.By;
const driver = new selenium.Builder().forBrowser("chrome").build();
So if I copy this in it won't actually run the commands in the same order so at least one variable returns as undeclared.
I've also tried typing in the commands separately but what this does is return the URL as undefined. It doesn't seem to recognise the environment variable as string.
This is the error returned when typing in the commands separately
> WebDriverError: unknown error: 'url' must be a string
I wonder if this is a common problem for Windows and if there#s any workarounds?
set command defines a temporary environment variable in CMD and Powershell, if you are using Git Bash then you can use the
export command instead which is the bash equivalent of
Brian Haucke13,717 Points
I ran into similar trouble with the environment variable not working correctly. When I tried it, driver.get(process.env.URL) would not bring up the webpage and I would have to set the URL as a variable in Node, then do driver.get(URL)
When I checked my Node version (node -v), it was the most recent version - 8.5.0. I had installed this previously for a separate project I was working on.
Looking at the Node website, it recommends most users use v6.x.x
I decided to try installing an earlier version of Node: v6.11.3.
Once I installed the older version, everything ran perfectly.
If you are running into similar issues, check what version of Node you have installed.
If you need to install an older version (like I did) I recommend Googling how to install an older version of Node.
Downgrading Node on my Mac was relatively simple (a few terminal commands and I was done), but it may be different depending on your computer / OS.