selenium×pythonを使い商品登録をしたいと思っています
seleniumIDEを使いコードを取得しました。
画像の登録など最初の段階ではうまくいっていたのですが、エラーが出て思うように動かなくなりました。
エラー部分を検索したのですが、いまいち原因が特定できずに困っています。
ご教授いただければ幸いです。よろしくお願いいたします。
ソースコード
># -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
class UntitledTestCase(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "https://www.katalon.com/"
self.verificationErrors = []
self.accept_next_alert = True
def test_untitled_test_case(self):
driver = self.driver
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True
def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True
def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
エラー内容
>E
======================================================================
ERROR: test_untitled_test_case (__main__.UntitledTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/shogo/anaconda3/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Users/shogo/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/Users/shogo/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/shogo/Desktop/\u6cb3\u91ce\u662d\u543e/flil.py", line 12, in setUp
self.driver = webdriver.Firefox()
File "/Users/shogo/anaconda3/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 152, in __init__
self.service.start()
File "/Users/shogo/anaconda3/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
----------------------------------------------------------------------
Ran 1 test in 0.014s
FAILED (errors=1)
[Finished in 0.381s]