having trouble running selenium on kali linux python chrome

207 views
Skip to first unread message

Eli Ceno

unread,
Mar 7, 2021, 12:49:05 PM3/7/21
to Selenium Users

#SelemiumTest
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import time

driver_location = "/usr/bin/chromedriver "
binary_location = "/usr/bin/google-chrome "

options = webdriver.ChromeOptions()
options_binary_location = binary_location

driver = webdriver.Chrome(executable_path=driver_location, chrome_options=options)
driver.get("http://www.imdb.com")

print("landing page ------>")
print("current_url", driver.current_url)
print("title", driver.title)

WAIT_ELEMENT = 30
XPATH_VALUE = "//*[@id=\"imdbHeader\"]/div[2]/div[5]/a/div"
x = WebDriverWait(driver, WAIT_ELEMENT).until(EC.presence_of_element_located((By.XPATH, XPATH_VALUE)))
outer = x.get_attribute('outerHTML')
print("outerHTML")
time.sleep(5)
x.click()

print("\n","signinin page ------->")
print("current_url", driver.current_url)
print("title", driver.title)

driver.close()
driver.quit()

my code

and  error
/home/?/selenium/main.py:14: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Chrome(executable_path=driver_location, chrome_options=options)
/home/?/selenium/main.py:14: DeprecationWarning: use options instead of chrome_options
  driver = webdriver.Chrome(executable_path=driver_location, chrome_options=options)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/selenium/webdriver/common/service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.9/subprocess.py", line 1823, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/chromedriver '

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/?/selenium/main.py", line 14, in <module>
    driver = webdriver.Chrome(executable_path=driver_location, chrome_options=options)
  File "/usr/lib/python3/dist-packages/selenium/webdriver/chrome/webdriver.py", line 92, in __init__
    self.service.start()
  File "/usr/lib/python3/dist-packages/selenium/webdriver/common/service.py", line 81, in start
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'chromedriver ' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


Process finished with exit code 1

Reply all
Reply to author
Forward
0 new messages