Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

  The code is failing after the first line. I have reinstalled Google Chrome, reinstalled the webdriver, and selenium, however I can't seem to resolve the issue. 

I am trying to use selenium and python using chromedriver, but I can't seem to get past a string of errors. I've troubleshooted using just about everything. Any help would be greatly appreciated!

from selenium import webdriver

os.environ["webdriver.chrome.driver"] = chromedriver

# browser = webdriver.Chrome(chromedriver)

# browser.get("https://www.google.com")

# title = browser.title

# print(title)

Here is the Code I have tried. I've also tried this...

from selenium import webdriver

# browser = webdriver.Chrome()

# browser.get("https://www.google.com")

# title = browser.title

# print(title)

I expect it to launch a webpage, however, I just get a string of errors.

Traceback (most recent call last):

  File "/Users/trapbookpro/Downloads/PythonLoginScripts/yes.py", line 1, in <module>

    from selenium import webdriver

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/__init__.py", line 18, in <module>

    from .firefox.webdriver import WebDriver as Firefox  # noqa

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 29, in <module>

    from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 21, in <module>

    import copy

  File "/Users/trapbookpro/Downloads/PythonLoginScripts/copy.py", line 10, in <module>

    lst1() 

1 Answer

0 votes
by (62.9k points)

You just need to add driver path like:

driver_path = r'your driver path'

browser = webdriver.Chrome(executable_path=driver_path)

and get titles like :

from selenium import webdriver driver_path = r'your path' browser = webdriver.Chrome(executable_path=driver_path) browser.get("https://intellipaat.com/") title = browser.title print(title)

Output :

NYU Login

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...