Selenium and Python: AttributeError: 'str' object has no attribute

741 views Asked by At

this seems to be a string problem since i have chromedriver, selenium and python installed. selenium has been downgraded to 4.9 like it was advised and the code was even redone to work better with python3. the original error was 'str' object has no attribute '_ignore_local_proxy' but continues to be 'str' related no matter how much i change??? here is the py file:

import sys
import datetime
import selenium
import requests
import time as t

from sys import stdout
from selenium import webdriver
from optparse import OptionParser
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--proxy-server=http://ipaddress:port')
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By


#extra code taken
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.ignore_local_proxy_environment_variables()

#Config#
parser = OptionParser()
now = datetime.datetime.now()

CHROME_DVR_DIR = 'C:\webdrivers\chromedriver.exe'

 driver = webdriver.Chrome(CHROME_DVR_DIR)
    optionss = webdriver.ChromeOptions()
    optionss.add_argument("--disable-popup-blocking")
    optionss.add_argument("--disable-extensions")
    count = 1 #count
    browser = webdriver.Chrome(CHROME_DVR_DIR) # Exception: Tried to use proxy
    wait = WebDriverWait(browser, 10)

everything is installed and up to date but im of course a kali linux beginner...

1

There are 1 answers

0
arash.shx On

Do not pass CHROME_DVR_DIR to webdriver.Chrome(CHROME_DVR_DIR).

Instead, move the chromedriver.exe file to your project folder, then write:

driver = webdriver.Chrome()

Do not change the rest of the code.