name 'driver' not defined, Selenium Webdriver python3
I'm trying to open a website using Selenium WebDriver Chrome, but haven't even gotten to that as my code keeps producing errors. I have already fixed one by doubling the '' in the directory for Chrome Driver.
I am using Pycharm. I would like to know why this is happening, and a fix for it.
The error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'driver' is not defined
and this is my code:
from selenium import webdriver
Browser = driver.Chrome(r'''C:UsersballcDownloadschromedriver_win32chromedriver.exe''')
python-3.x selenium selenium-webdriver webdriver pycharm
|
show 3 more comments
I'm trying to open a website using Selenium WebDriver Chrome, but haven't even gotten to that as my code keeps producing errors. I have already fixed one by doubling the '' in the directory for Chrome Driver.
I am using Pycharm. I would like to know why this is happening, and a fix for it.
The error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'driver' is not defined
and this is my code:
from selenium import webdriver
Browser = driver.Chrome(r'''C:UsersballcDownloadschromedriver_win32chromedriver.exe''')
python-3.x selenium selenium-webdriver webdriver pycharm
you importedwebdriver
, what should bedriver
?
– PRMoureu
Jun 16 '18 at 10:55
@PRMoureu is it not supposed to be webdriver? I just used driver instead, it said "no module named driver"
– Noah
Jun 16 '18 at 11:09
you are supposed to importwebdriver
but why not using it instead ofdriver
?
– PRMoureu
Jun 16 '18 at 11:11
@PRMoureu i did import webdriver do you mean driver.Chrome?
– Noah
Jun 16 '18 at 11:18
yup! whatdriver.Chrome
is supposed to be ? why don't you want to usewebdriver.Chrome
instead ?
– PRMoureu
Jun 16 '18 at 11:25
|
show 3 more comments
I'm trying to open a website using Selenium WebDriver Chrome, but haven't even gotten to that as my code keeps producing errors. I have already fixed one by doubling the '' in the directory for Chrome Driver.
I am using Pycharm. I would like to know why this is happening, and a fix for it.
The error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'driver' is not defined
and this is my code:
from selenium import webdriver
Browser = driver.Chrome(r'''C:UsersballcDownloadschromedriver_win32chromedriver.exe''')
python-3.x selenium selenium-webdriver webdriver pycharm
I'm trying to open a website using Selenium WebDriver Chrome, but haven't even gotten to that as my code keeps producing errors. I have already fixed one by doubling the '' in the directory for Chrome Driver.
I am using Pycharm. I would like to know why this is happening, and a fix for it.
The error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'driver' is not defined
and this is my code:
from selenium import webdriver
Browser = driver.Chrome(r'''C:UsersballcDownloadschromedriver_win32chromedriver.exe''')
python-3.x selenium selenium-webdriver webdriver pycharm
python-3.x selenium selenium-webdriver webdriver pycharm
edited Jun 16 '18 at 19:40
DebanjanB
44.7k134588
44.7k134588
asked Jun 16 '18 at 10:51
Noah Noah
76
76
you importedwebdriver
, what should bedriver
?
– PRMoureu
Jun 16 '18 at 10:55
@PRMoureu is it not supposed to be webdriver? I just used driver instead, it said "no module named driver"
– Noah
Jun 16 '18 at 11:09
you are supposed to importwebdriver
but why not using it instead ofdriver
?
– PRMoureu
Jun 16 '18 at 11:11
@PRMoureu i did import webdriver do you mean driver.Chrome?
– Noah
Jun 16 '18 at 11:18
yup! whatdriver.Chrome
is supposed to be ? why don't you want to usewebdriver.Chrome
instead ?
– PRMoureu
Jun 16 '18 at 11:25
|
show 3 more comments
you importedwebdriver
, what should bedriver
?
– PRMoureu
Jun 16 '18 at 10:55
@PRMoureu is it not supposed to be webdriver? I just used driver instead, it said "no module named driver"
– Noah
Jun 16 '18 at 11:09
you are supposed to importwebdriver
but why not using it instead ofdriver
?
– PRMoureu
Jun 16 '18 at 11:11
@PRMoureu i did import webdriver do you mean driver.Chrome?
– Noah
Jun 16 '18 at 11:18
yup! whatdriver.Chrome
is supposed to be ? why don't you want to usewebdriver.Chrome
instead ?
– PRMoureu
Jun 16 '18 at 11:25
you imported
webdriver
, what should be driver
?– PRMoureu
Jun 16 '18 at 10:55
you imported
webdriver
, what should be driver
?– PRMoureu
Jun 16 '18 at 10:55
@PRMoureu is it not supposed to be webdriver? I just used driver instead, it said "no module named driver"
– Noah
Jun 16 '18 at 11:09
@PRMoureu is it not supposed to be webdriver? I just used driver instead, it said "no module named driver"
– Noah
Jun 16 '18 at 11:09
you are supposed to import
webdriver
but why not using it instead of driver
?– PRMoureu
Jun 16 '18 at 11:11
you are supposed to import
webdriver
but why not using it instead of driver
?– PRMoureu
Jun 16 '18 at 11:11
@PRMoureu i did import webdriver do you mean driver.Chrome?
– Noah
Jun 16 '18 at 11:18
@PRMoureu i did import webdriver do you mean driver.Chrome?
– Noah
Jun 16 '18 at 11:18
yup! what
driver.Chrome
is supposed to be ? why don't you want to use webdriver.Chrome
instead ?– PRMoureu
Jun 16 '18 at 11:25
yup! what
driver.Chrome
is supposed to be ? why don't you want to use webdriver.Chrome
instead ?– PRMoureu
Jun 16 '18 at 11:25
|
show 3 more comments
3 Answers
3
active
oldest
votes
from selenium import webdriver
you can see the module name is webdriver
, so you should use that name. As the error states, driver
is not defined (you never defined it).
so..
Browser = driver.Chrome()
should be:
browser = webdriver.Chrome()
add a comment |
Try this code :
from selenium import webdriver
driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
driver.get("https://www.google.com/")
Can you please give the update on this ?
– cruisepandey
Jun 19 '18 at 15:02
add a comment |
As you have imported webdriver
module as:
from selenium import webdriver
- To invoke Chrome through ChromeDriver you need to use the same
webdriver
module. - While passing the path of the ChromeDriver you need to mention the Key executable_path along with the Value i.e. the absolute path within single quotes (
''
) separated through single forward slash () along with the raw (
r
) switch.
Try to avoid names of common builtin variables e.g.Browser to avoid cyclic dependencies.
driver = webdriver.Chrome(executable_path=r'C:UsersballcDownloadschromedriver_win32chromedriver.exe')
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50887238%2fname-driver-not-defined-selenium-webdriver-python3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
from selenium import webdriver
you can see the module name is webdriver
, so you should use that name. As the error states, driver
is not defined (you never defined it).
so..
Browser = driver.Chrome()
should be:
browser = webdriver.Chrome()
add a comment |
from selenium import webdriver
you can see the module name is webdriver
, so you should use that name. As the error states, driver
is not defined (you never defined it).
so..
Browser = driver.Chrome()
should be:
browser = webdriver.Chrome()
add a comment |
from selenium import webdriver
you can see the module name is webdriver
, so you should use that name. As the error states, driver
is not defined (you never defined it).
so..
Browser = driver.Chrome()
should be:
browser = webdriver.Chrome()
from selenium import webdriver
you can see the module name is webdriver
, so you should use that name. As the error states, driver
is not defined (you never defined it).
so..
Browser = driver.Chrome()
should be:
browser = webdriver.Chrome()
answered Jun 16 '18 at 14:48
Corey GoldbergCorey Goldberg
37.9k22110125
37.9k22110125
add a comment |
add a comment |
Try this code :
from selenium import webdriver
driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
driver.get("https://www.google.com/")
Can you please give the update on this ?
– cruisepandey
Jun 19 '18 at 15:02
add a comment |
Try this code :
from selenium import webdriver
driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
driver.get("https://www.google.com/")
Can you please give the update on this ?
– cruisepandey
Jun 19 '18 at 15:02
add a comment |
Try this code :
from selenium import webdriver
driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
driver.get("https://www.google.com/")
Try this code :
from selenium import webdriver
driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
driver.get("https://www.google.com/")
answered Jun 16 '18 at 16:21
cruisepandeycruisepandey
4,2962619
4,2962619
Can you please give the update on this ?
– cruisepandey
Jun 19 '18 at 15:02
add a comment |
Can you please give the update on this ?
– cruisepandey
Jun 19 '18 at 15:02
Can you please give the update on this ?
– cruisepandey
Jun 19 '18 at 15:02
Can you please give the update on this ?
– cruisepandey
Jun 19 '18 at 15:02
add a comment |
As you have imported webdriver
module as:
from selenium import webdriver
- To invoke Chrome through ChromeDriver you need to use the same
webdriver
module. - While passing the path of the ChromeDriver you need to mention the Key executable_path along with the Value i.e. the absolute path within single quotes (
''
) separated through single forward slash () along with the raw (
r
) switch.
Try to avoid names of common builtin variables e.g.Browser to avoid cyclic dependencies.
driver = webdriver.Chrome(executable_path=r'C:UsersballcDownloadschromedriver_win32chromedriver.exe')
add a comment |
As you have imported webdriver
module as:
from selenium import webdriver
- To invoke Chrome through ChromeDriver you need to use the same
webdriver
module. - While passing the path of the ChromeDriver you need to mention the Key executable_path along with the Value i.e. the absolute path within single quotes (
''
) separated through single forward slash () along with the raw (
r
) switch.
Try to avoid names of common builtin variables e.g.Browser to avoid cyclic dependencies.
driver = webdriver.Chrome(executable_path=r'C:UsersballcDownloadschromedriver_win32chromedriver.exe')
add a comment |
As you have imported webdriver
module as:
from selenium import webdriver
- To invoke Chrome through ChromeDriver you need to use the same
webdriver
module. - While passing the path of the ChromeDriver you need to mention the Key executable_path along with the Value i.e. the absolute path within single quotes (
''
) separated through single forward slash () along with the raw (
r
) switch.
Try to avoid names of common builtin variables e.g.Browser to avoid cyclic dependencies.
driver = webdriver.Chrome(executable_path=r'C:UsersballcDownloadschromedriver_win32chromedriver.exe')
As you have imported webdriver
module as:
from selenium import webdriver
- To invoke Chrome through ChromeDriver you need to use the same
webdriver
module. - While passing the path of the ChromeDriver you need to mention the Key executable_path along with the Value i.e. the absolute path within single quotes (
''
) separated through single forward slash () along with the raw (
r
) switch.
Try to avoid names of common builtin variables e.g.Browser to avoid cyclic dependencies.
driver = webdriver.Chrome(executable_path=r'C:UsersballcDownloadschromedriver_win32chromedriver.exe')
edited Jun 16 '18 at 20:09
answered Jun 16 '18 at 19:54
DebanjanBDebanjanB
44.7k134588
44.7k134588
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f50887238%2fname-driver-not-defined-selenium-webdriver-python3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you imported
webdriver
, what should bedriver
?– PRMoureu
Jun 16 '18 at 10:55
@PRMoureu is it not supposed to be webdriver? I just used driver instead, it said "no module named driver"
– Noah
Jun 16 '18 at 11:09
you are supposed to import
webdriver
but why not using it instead ofdriver
?– PRMoureu
Jun 16 '18 at 11:11
@PRMoureu i did import webdriver do you mean driver.Chrome?
– Noah
Jun 16 '18 at 11:18
yup! what
driver.Chrome
is supposed to be ? why don't you want to usewebdriver.Chrome
instead ?– PRMoureu
Jun 16 '18 at 11:25