Hello, trying to run the following script:

import unittest from selenium import webdriver from selenium.webdriver.support.ui import Select class SearchByJobTitle(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "http://hrm.seleniumminutes.com" self.verificationErrors = [] self.accept_next_alert = True def test_search_for_qa_manager(self): driver = self.driver driver.get(self.base_url) self.assertEqual("OrangeHRM", driver.title) driver.find_element_by_id("txtUsername").clear() driver.find_element_by_id("txtUsername").send_keys("123") driver.find_element_by_id("txtPassword").clear() driver.find_element_by_id("txtPassword").send_keys("1234") driver.find_element_by_id("btnLogin").click() self.assertEqual("OrangeHRM", driver.title) driver.find_element_by_css_selector("#menu_pim_viewPimModule > b").click() Select(driver.find_element_by_id("empsearch_job_title")).select_by_visible_text( "QA Manager") driver.find_element_by_id("searchBtn").click() self.assertEqual("OrangeHRM", driver.title) # OPTION #1 # retrieve 5th cell from all rows in the table all_results = driver.find_elements_by_xpath("//table[@id='resultTable']/tbody/tr/td[5]") # loop through each resulting element for single_result in all_results: # check the text of each 5th cell to ensure in contains QA Manager self.assertEqual("QA Manager", single_result.text) # OPTION #2 # retrieve all rows in the table all_rows = driver.find_elements_by_xpath("//table[@id='resultTable']/tbody/tr") # loop through each resulting row for row in all_rows: # check the text of each 5th cell to ensure in contains QA Manager self.assertEqual("QA Manager", row.find_element_by_xpath('.//td[5]').text) driver.find_element_by_id("welcome").click() driver.find_element_by_link_text("Logout").click() self.assertEqual("OrangeHRM", driver.title) def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) if __name__ == "__main__": unittest.main() 

Trying to execute the script in PyCharm, Selenium and Python installed. In the code, as far as I can see, everything is correct. I can not understand how to solve the problem, I have been trying to install different versions of Python and Selenium for 2 hours already, the error is the same, although it runs on another computer (Windows) without any problems. Tell me, please, what's the problem? I'm trying to run on a poppy.

Here is such a mistake:

 Ran 1 test in 0.060s FAILED (errors=1) Error Traceback (most recent call last): File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 322, in run self.setUp() File "/Users/myname/Desktop/HRM2017/HW5_SearchByJobTitle.py", line 10, in setUp self.driver = webdriver.Firefox() File "/Users/myname/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/firefox/webdriver.py", line 144, in __init__ self.service.start() File "/Users/mynane/Library/Python/2.7/lib/python/site-packages/selenium/webdriver/common/service.py", line 81, in start os.path.basename(self.path), self.start_error_message) WebDriverException: Message: 'geckodriver' executable needs to be in PATH. Process finished with exit code 1 

1 answer 1

1 You need to download geckodriver . You can take it here.

2 a) You can simply register the path to geckodriver in PATH.

b) Or you can do this:

 self.driver= webdriver.Firefox(executable_path='your\path\to\geckodriver')