3

When running this simple code a blank page opens with 'data:,' written in the url. Chrome driver is the correct version (ChromeDriver 81.0.4044.69) and matches my GoogleChrome version (81.0.4044.122). Selenium updated also (3.141.0)

I have also added the driver's folder to the systems' PATH. Also tried with http instead of https in the url.

from selenium import webdriver

class GoogleBot:
def __init__(self):
    self.driver = webdriver.Chrome(executable_path="C:\Drivers\chromedriver.exe")
    driver.get("https://www.google.es/")


GoogleBot()

Screenshot.jpeg

General Grievance
  • 4,555
  • 31
  • 31
  • 45
PythonRayson
  • 31
  • 1
  • 4

1 Answers1

2

In your code you have used driver intead of self.driver. please refer below code to resolve your issue ::

from selenium import webdriver

class GoogleBot:

    def __init__(self):
        self.driver = webdriver.Chrome(executable_path=r"path for chromedriver.exe")

    def googleTest(self):
        self.driver.get("https://www.google.es/")
        self.driver.close()

if __name__ == "__main__":
    GoogleBot = GoogleBot()
    GoogleBot.googleTest()
SeleniumUser
  • 4,065
  • 2
  • 7
  • 30
  • I tried writing `self.driver` and nothing changed. I noticed that when I pass no argument to webriver.Chrome() it opens the same blank 'data:,' page. – PythonRayson Apr 26 '20 at 07:30
  • try to restart your machine and give a try because i dont think so its a compabbility issue tbh. – SeleniumUser Apr 26 '20 at 08:00
  • I now downloaded Firefox along with geckodriver. `from selenium import webdriver driver = webdriver.Firefox(executable_path='C:\Drivers\geckodriver.exe') driver.get('https://www.google.es/') ` This code gives me the error that says that CHROMEDRIVER is not in PATH. Why does it open Chrome by default? Does this help in in main problem? – PythonRayson Apr 26 '20 at 08:11
  • check if you are calling correct program , or else check in your code if there is a iniitialization is done for a chrome – SeleniumUser Apr 26 '20 at 08:26
  • SOLVED. My bad, when using shortcut for RUN i was running another python file. Thank you so much anyways my dear friend! – PythonRayson Apr 26 '20 at 08:44