Selenium не запускает браузер - Python
Формулировка задачи:
Установил Selenium 3.0.0b3. Но до запуска браузера дело не доходит... Выдает следующее.
Это что-то не то с "geckodriver"? Его отдельно ставить или как? Читал readme к селениуму - там ничего на этот счет не говориться.
У меня стоит "Mozilla Firefox 49.0"
Листинг программы
- Traceback (most recent call last):
- File "/usr/local/lib/python3.4/dist-packages/selenium-3.0.0.b3-py3.4.egg/selenium/webdriver/common/service.py", line 64, in start
- stdout=self.log_file, stderr=self.log_file)
- File "/usr/lib/python3.4/subprocess.py", line 859, in __init__
- restore_signals, start_new_session)
- File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child
- raise child_exception_type(errno_num, err_msg)
- FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
- During handling of the above exception, another exception occurred:
- Traceback (most recent call last):
- File "./selen.py", line 5, in <module>
- driver = webdriver.Firefox()
- File "/usr/local/lib/python3.4/dist-packages/selenium-3.0.0.b3-py3.4.egg/selenium/webdriver/firefox/webdriver.py", line 68, in __init__
- self.service.start()
- File "/usr/local/lib/python3.4/dist-packages/selenium-3.0.0.b3-py3.4.egg/selenium/webdriver/common/service.py", line 71, in start
- os.path.basename(self.path), self.start_error_message)
- selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
- Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x7f3d46276cf8>>
- Traceback (most recent call last):
- File "/usr/local/lib/python3.4/dist-packages/selenium-3.0.0.b3-py3.4.egg/selenium/webdriver/common/service.py", line 163, in __del__
- self.stop()
- File "/usr/local/lib/python3.4/dist-packages/selenium-3.0.0.b3-py3.4.egg/selenium/webdriver/common/service.py", line 135, in stop
- if self.process is None:
- AttributeError: 'Service' object has no attribute 'process'
Решение задачи: «Selenium не запускает браузер»
textual
Листинг программы
- #! /usr/bin/python3
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- driver = webdriver.Firefox()
- driver.get("http://www.python.org")
- assert "Python" in driver.title
- elem = driver.find_element_by_name("q")
- elem.clear()
- elem.send_keys("pycon")
- elem.send_keys(Keys.RETURN)
- assert "No results found." not in driver.page_source
- driver.close()
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д