'Getting an error in pycharm ,of TypeError in python selenium
--->This is my one file booking.py
from selenium import webdriver
import os
class Task(webdriver.Chrome):
def __init__(self,
driver_path=webdriver.Chrome(executable_path=r"/home/mank/Documents/webdriver/chromedriver")):
self.driver_path = driver_path
os.environ['PATH'] += self.driver_path
super(Task, self).__init__()
self.implicitly_wait(10)
self.maximize_window()
self.get('https://www.sample.com/')
- this 2nd file of run.py
from bot.booking import Task
with Task() as bot:
bot.landing_page()
print("exiting..")
---->Trying to run by run.py .Please check and let me know ,Thanks
Error message of :
Traceback (most recent call last):
File "/home/mank/PycharmProjects/botnew/bot/run.py", line 3, in <module>
with Task() as bot:
File "/home/mank/PycharmProjects/botnew/bot/booking.py", line 14, in __init__
os.environ['PATH'] +=self.driver_path
TypeError: can only concatenate str (not "WebDriver") to str
Solution 1:[1]
self.driver_path is of type WebDriver but in your code it is treated like a string.
So your code fails in the line os.environ['PATH'] += self.driver_path - just removing the line should fix the current error message.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Patrick Klein |
