Home > Software engineering >  Getting an error in pycharm ,of TypeError in python selenium
Getting an error in pycharm ,of TypeError in python selenium

Time:05-11

--->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/')
  1. 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

CodePudding user response:

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.

CodePudding user response:

Okay so i tried to do that way,still got the error . so with hit and trial ,type error for it was right ,so i change notation for driver path, and in my bin folder -> copied the chromedriver in it. Thanks by the way for efforts , as i was not able to clarify my question,i will improve with next time.

  • Related