name 'driver' not defined, Selenium Webdriver python3












-2















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''')









share|improve this question

























  • 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













  • 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











  • 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
















-2















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''')









share|improve this question

























  • 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













  • 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











  • 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














-2












-2








-2


1






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''')









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 16 '18 at 19:40









DebanjanB

44.7k134588




44.7k134588










asked Jun 16 '18 at 10:51









Noah Noah

76




76













  • 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













  • 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











  • 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



















  • 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













  • 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











  • 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

















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












3 Answers
3






active

oldest

votes


















1















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()






share|improve this answer































    0














    Try this code :



    from selenium import webdriver  

    driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
    driver.get("https://www.google.com/")





    share|improve this answer
























    • Can you please give the update on this ?

      – cruisepandey
      Jun 19 '18 at 15:02



















    0














    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')







    share|improve this answer

























      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
      });


      }
      });














      draft saved

      draft discarded


















      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









      1















      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()






      share|improve this answer




























        1















        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()






        share|improve this answer


























          1












          1








          1








          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()






          share|improve this answer














          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()







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jun 16 '18 at 14:48









          Corey GoldbergCorey Goldberg

          37.9k22110125




          37.9k22110125

























              0














              Try this code :



              from selenium import webdriver  

              driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
              driver.get("https://www.google.com/")





              share|improve this answer
























              • Can you please give the update on this ?

                – cruisepandey
                Jun 19 '18 at 15:02
















              0














              Try this code :



              from selenium import webdriver  

              driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
              driver.get("https://www.google.com/")





              share|improve this answer
























              • Can you please give the update on this ?

                – cruisepandey
                Jun 19 '18 at 15:02














              0












              0








              0







              Try this code :



              from selenium import webdriver  

              driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
              driver.get("https://www.google.com/")





              share|improve this answer













              Try this code :



              from selenium import webdriver  

              driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
              driver.get("https://www.google.com/")






              share|improve this answer












              share|improve this answer



              share|improve this answer










              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



















              • 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











              0














              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')







              share|improve this answer






























                0














                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')







                share|improve this answer




























                  0












                  0








                  0







                  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')







                  share|improve this answer















                  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')








                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jun 16 '18 at 20:09

























                  answered Jun 16 '18 at 19:54









                  DebanjanBDebanjanB

                  44.7k134588




                  44.7k134588






























                      draft saved

                      draft discarded




















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Xamarin.iOS Cant Deploy on Iphone

                      Glorious Revolution

                      Dulmage-Mendelsohn matrix decomposition in Python