Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Python Selenium Faliure SyntaxWarning: invalid escape sequence '\C' AttributeError: 'str' object has no attribute 'capabilities'

$
0
0

I am trying to run my first automation of Python Selenium on PyCharm Community Edition:

from selenium import webdriverdriver = webdriver.Chrome("C:\Code\Drivers\Chrome\chromedriver.exe")driver.get('https://opensource-demo.orangehrmlive.com/')

Then I got the following failure message, I am very grateful if anyone can help me find the reason:enter image description hereenter image description here

C:\Code\PythonSelenium\PythonSelenium\venv\Scripts\python.exe C:\Code\PythonSelenium\PythonSelenium\selenium\FirstTestCase.py C:\Code\PythonSelenium\PythonSelenium\selenium\FirstTestCase.py:2: SyntaxWarning: invalid escape sequence '\C'  driver = webdriver.Chrome("C:\Code\Drivers\Chrome\chromedriver.exe")Traceback (most recent call last):  File "C:\Code\PythonSelenium\PythonSelenium\venv\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 38, in get_path    path = SeleniumManager().driver_location(options) if path is None else path           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Code\PythonSelenium\PythonSelenium\venv\Lib\site-packages\selenium\webdriver\common\selenium_manager.py", line 84, in driver_location    browser = options.capabilities["browserName"]              ^^^^^^^^^^^^^^^^^^^^AttributeError: 'str' object has no attribute 'capabilities'During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "C:\Code\PythonSelenium\PythonSelenium\selenium\FirstTestCase.py", line 2, in <module>    driver = webdriver.Chrome("C:\Code\Drivers\Chrome\chromedriver.exe")C:\Code\PythonSelenium\PythonSelenium\selenium\FirstTestCase.py:1: SyntaxWarning: invalid escape sequence '\C'  from selenium import webdriver             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Code\PythonSelenium\PythonSelenium\venv\Lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 45, in __init__    super().__init__(  File "C:\Code\PythonSelenium\PythonSelenium\venv\Lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 49, in __init__    self.service.path = DriverFinder.get_path(self.service, options)                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "C:\Code\PythonSelenium\PythonSelenium\venv\Lib\site-packages\selenium\webdriver\common\driver_finder.py", line 40, in get_path    msg = f"Unable to obtain driver for {options.capabilities['browserName']} using Selenium Manager."                                         ^^^^^^^^^^^^^^^^^^^^AttributeError: 'str' object has no attribute 'capabilities'

I am very grateful if anyone can help me find the reason:


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>