0

sorry for the silly question, but I'm trying to run a very simple python script using selenium. Heres the script I have,

from selenium
import webdriver

driver = webdriver.Chrome(executable_path = "/usr/local/caskroom/chromedriver/chromedriver.exe")

driver.get("https://www.google.com")

its giving me the following error,

 from selenium
                 ^
SyntaxError: invalid syntax

Process finished with exit code 1

I've installed selenium, and chrome driver so not sure what the problem is, any help would be greatly appreciated. Thanks

Zac Anger
  • 6,983
  • 2
  • 15
  • 42
newb81
  • 1
  • 1

2 Answers2

1

A linebreak there isn't valid. from selenium import webdriver, on the same line.

Zac Anger
  • 6,983
  • 2
  • 15
  • 42
  • Thanks Zac, that worked, the script runs, however I'm getting a warning DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = webdriver.Chrome(executable_path = "/usr/local/caskroom/chromedriver/chromedriver.exe") – newb81 May 02 '23 at 12:30
  • @newb81 check out the [migration docs](https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/) for how to adjust for Selenium 4, as well as [this answer](https://stackoverflow.com/a/70099102/5774952) with more details. – Zac Anger May 02 '23 at 12:57
0
# import required modules
from selenium import webdriver
 
# Driver Code
if __name__ == '__main__':
 
    # create object
    edgeBrowser = webdriver.Edge(r"msedgedriver.exe")
 
    # open browser and navigate to facebook
    edgeBrowser.get('https://www.facebook.com')
General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Ben the Coder May 04 '23 at 13:51