Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Quality Assurance Introduction to Selenium Test Drive Selenium Installation

Nikita Novikov
Nikita Novikov
5,929 Points

Uncaught ReferenceError: driver is not defined

After typing "driver.get(url);" I got "Uncaught ReferenceError: driver is not defined" error message. How do i solve this problem?

Steven Parker
Steven Parker
217,577 Points

You need to provide more information. Take a look at this video about Posting a Question), and perhaps also this one about sharing a snapshot of your workspace.

Caleb Kemp
Caleb Kemp
12,677 Points

I am glad Steven Parker mentioned that, without sufficient information, it isn't always possible to find a solution. I don't know for certain, but from what you posted, I think you might have an iframe reference (scope) problem. Let me see if I can show you what I mean by that. In the following code, we see that even though we have let max = 5 higher up in the code, running console.log(max) will cause an error because they are not of the same scope. The variable max has not been defined outside the "if" block.

if(1 == 1){
  let max = 5;

In the case of iframe's, you can have something similar, something like the following

    const driver = new selenium.build;
  //I think you can see how running "driver.get" here will cause a reference error because it is out of scope

To fix this, we have to make sure that your "driver.get(url)" call is in the correct scope. Adding something like the following before your "driver.get(url)" call may do the trick.

//here within iframe (child)

Here is a link to a post a person's explanation of this. I don't know 100% this is your problem, however, it does seem reasonably likely from the information posted. Hope that helps!