Selenium geht nicht?

3 Antworten

Du darfst den Pfad meines wissens nicht an firefox übergeben

Aber schön dass du noch firefox nutzt!


bycrix1 
Fragesteller
 17.10.2020, 10:33
Aber schön dass du noch firefox nutzt!

Ich benutze die Mülltonne lediglich für die Automatisierung, weil es keinen driver für brave gibt...

0
bycrix1 
Fragesteller
 18.10.2020, 21:52
@derfragemast717

Ja klar, ich habe selber mehrere Jahre Firefox genutzt. Das Ding is langsam af.

0

"gekodriver.exe" sollte sich im gleichen Pfad befinden wie der Script den du gemacht hast.

Ansonsten kannst du den Pfad auch manuell angeben:

browser = webdriver.Firefox(executable_path='C:\*PATH*\gekodriver.exe')
Woher ich das weiß:eigene Erfahrung

bycrix1 
Fragesteller
 16.10.2020, 00:12

Habe das jetzt gemacht, geht aber trotzdem nicht :/

Traceback (most recent call last):
  File "C:\Users\tkoll\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\tkoll\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 267, in run_file
    runpy.run_path(options.target, run_name=compat.force_str("__main__"))
  File "C:\Users\tkoll\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 267, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "C:\Users\tkoll\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 242, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
  File "C:\Users\tkoll\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py", line 5
    driver = webdriver.Firefox("C:\Users\tkoll\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.9\Browser\geckodriver.exe")
                                                                                                                                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape


0

Alles Wichtige steht schon da:

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
  1. Als vorbereitenden Schritt (falls noch nicht getan) am besten den aktuellen Geckodriver installieren https://github.com/mozilla/geckodriver/releases).
  2. PATH-Umgebungsvariable setzen (der Installationspfad des Geckodriver (also der Ordner, in dem die Executable liegt) wird ihr angehängt (Tutorial für Windows).
  3. Programm neustarten (oder den Rechner, falls es nicht instant wirkt)

bycrix1 
Fragesteller
 16.10.2020, 00:12

Habe das jetzt gemacht, geht aber trotzdem nicht :/

Traceback (most recent call last):
  File "C:\Users\tkoll\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\tkoll\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\program files (x86)\microsoft visual studio\2019\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 267, in run_file
    runpy.run_path(options.target, run_name=compat.force_str("__main__"))
  File "C:\Users\tkoll\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 267, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "C:\Users\tkoll\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 242, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
  File "C:\Users\tkoll\source\repos\PythonApplication1\PythonApplication1\PythonApplication1.py", line 5
    driver = webdriver.Firefox("C:\Users\tkoll\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.9\Browser\geckodriver.exe")
                                                                                                                                        ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Press any key to continue . . .




0
regex9  16.10.2020, 10:09
@bycrix1

Nein, hast du nicht. Ich habe nirgendwo geschrieben, dass du den Pfad zur Executable an die Firefox-Methode übergeben sollst, auch wenn das eine alternative Lösung sein mag.

Das Problem liegt bei den Backslashes im String. Entweder du maskierst sie mit einem vorhergehenden Backslash (\\) oder du verwendest einen Rawstring.

Beispiel:

print(r"c:\some\path")
1