Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
selenium error :
#1
hello all ...
im trying to use selenium i keep getting this error :

Error:
Traceback (most recent call last): File "c:/Users/root/Desktop/token.py", line 3, in <module> browser = webdriver.Firefox(executable_path=r"C:\Users\root\Desktop\geckodriver.exe") File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__ self.service.start() File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 95, in start (os.path.basename(self.path), self.start_error_message, str(e))) selenium.common.exceptions.WebDriverException: Message: The executable geckodriver.exe needs to be available in the path. 'module' object has no attribute 'system'
my code :
from selenium import webdriver

browser = webdriver.Firefox(executable_path=r"C:\Users\root\Desktop\geckodriver.exe")
browser.get('http://www.google.com')
when i run the code for the second time the error is :

Error:
Traceback (most recent call last): File "c:/Users/root/Desktop/token.py", line 1, in <module> from selenium import webdriver File "C:\Python27\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module> from .firefox.webdriver import WebDriver as Firefox # noqa File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 29, in <module> from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 27, in <module> from .remote_connection import RemoteConnection File "C:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 20, in <module> import platform File "c:\Users\root\Desktop\platform.py", line 4, in <module> os.makedirs(d+"/test") File "C:\Python27\lib\os.py", line 157, in makedirs mkdir(name, mode) WindowsError: [Error 183] Cannot create a file when that file already exists: 'C:\\Users\\root\\AppData\\Roaming/test'
Reply
#2
see: https://python-forum.io/Thread-Web-scraping-part-2

search for 'Headless(not loading browser):'

make sure you add options to your code.
Reply
#3
(Nov-11-2018, 09:46 AM)Larz60+ Wrote: see: https://python-forum.io/Thread-Web-scraping-part-2

search for 'Headless(not loading browser):'

make sure you add options to your code.

this is my new code :
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
import time
 
#--| Setup
options = Options()
options.set_headless(headless=True)
caps = webdriver.DesiredCapabilities().FIREFOX
caps["marionette"] = True
browser = webdriver.Firefox(firefox_options=options, capabilities=caps, executable_path=r"C:\Users\root\Desktop\geckodriver.exe")
#--| Parse
browser.get('https://www.python.org/')
time.sleep(2)
t = browser.find_element_by_xpath('//*[@id="dive-into-python"]/ul[2]/li[1]/div[1]/pre/code/span[1]')
print(t.text)
browser.quit()
and this is the new error :

Error:
Traceback (most recent call last): File "c:/Users/root/Desktop/token.py", line 10, in <module> browser = webdriver.Firefox(firefox_options=options, capabilities=caps, executable_path=r"C:\Users\root\Desktop\geckodriver.exe") File "C:\Python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__ self.service.start() File "C:\Python27\lib\site-packages\selenium\webdriver\common\service.py", line 95, in start (os.path.basename(self.path), self.start_error_message, str(e))) selenium.common.exceptions.WebDriverException: Message: The executable geckodriver.exe needs to be available in the path. 'module' object has no attribute 'system'
Reply
#4
is this the right path for geckodriver? C:\Users\root\Desktop\geckodriver.exe"
Reply
#5
(Nov-11-2018, 10:36 AM)Larz60+ Wrote: is this the right path for geckodriver? C:\Users\root\Desktop\geckodriver.exe"

yes
Reply
#6
(Nov-11-2018, 10:28 AM)evilcode1 Wrote: The executable geckodriver.exe needs to be available in the Path.
The mean Windows Environment Variables Path
So you look what's folder that's in Path and place geckodriver.exe there,
or you can add own folder to Path(Restart) eg C:\web_drivers.
Reply
#7
(Nov-11-2018, 11:29 AM)snippsat Wrote:
(Nov-11-2018, 10:28 AM)evilcode1 Wrote: The executable geckodriver.exe needs to be available in the Path.
The mean Windows Environment Variables Path
So you look what's folder that's in Path and place geckodriver.exe there,
or you can add own folder to Path(Restart) eg C:\web_drivers.
still nor work still the same last error
Reply
#8
(Nov-12-2018, 10:43 AM)evilcode1 Wrote: still nor work still the same last error
If have trouble with Path setup,just have geckodriver.exe in same folder as Scripts you run.
E:\div_code\scrape
|-- duck_go.py
|-- geckodriver.exe
# duck_go.py
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys
import time

#--| Setup
options = Options()
#options.add_argument("--headless")
caps = webdriver.DesiredCapabilities().FIREFOX
caps["marionette"] = True
browser = webdriver.Firefox(firefox_options=options, capabilities=caps, executable_path=r"geckodriver.exe")
#--| Parse or automation
browser.get('https://duckduckgo.com')
input_field = browser.find_elements_by_css_selector('#search_form_input_homepage')
input_field[0].send_keys('car' + Keys.RETURN)
time.sleep(3)
images_link = browser.find_elements_by_link_text('Images') #Or your country name of images
images_link[0].click()
time.sleep(5)
browser.quit()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium weird error julio2000 0 1,646 Feb-23-2020, 01:24 PM
Last Post: julio2000
  Selenium webdriver error WiPi 4 11,986 Feb-09-2020, 11:38 AM
Last Post: WiPi
  error when running headless selenium julio2000 2 4,508 Feb-01-2020, 12:41 PM
Last Post: julio2000
  Error clicking button with selenium julio2000 4 5,249 Jan-06-2020, 10:59 AM
Last Post: julio2000
  Selenium error with ebdriver (geckodriver) Martinelli 4 4,663 Sep-24-2019, 01:40 AM
Last Post: Martinelli
  Python Selenium .click() Loads Error - Works Manually.- Events not Triggered NSearch 24 11,524 Aug-14-2019, 02:23 PM
Last Post: NSearch
  Error when trying to use Selenium ejected 1 5,144 Mar-26-2019, 04:53 AM
Last Post: ejected
  Instagramlogin Error (Selenium) julian_veit 0 2,618 Jan-26-2019, 02:40 PM
Last Post: julian_veit
  Getting error when accessing elements in a modal window of an webpage using selenium sumandas89 3 8,573 Jul-13-2018, 10:44 AM
Last Post: mlieqo
  Python 3/selenium - nontype error water_fox 2 11,746 Jun-28-2018, 08:19 PM
Last Post: Sudhakar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020