0

I'm trying to run a simple automated test script. My code looks like:

import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

gecko = os.path.normpath(os.path.join(os.path.dirname(__file__), 'geckodriver'))
binary = FirefoxBinary('C:\Program Files (x86)\Mozilla Firefox\Firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path=gecko+'.exe')


class PythonOrgSearch(unittest.TestCase):
def setUp(self):
    self.driver = driver

def test_search_in_python_org(self):
    driver = self.driver
    driver.get("http://www.python.org")
    self.assertIn("Python", driver.title)
    elem = driver.find_element_by_name("q")
    elem.send_keys("pycon")
    elem.send_keys(Keys.RETURN)
    assert "No results found." not in driver.page_source


def tearDown(self):
    self.driver.close()

if __name__ == "__main__":
    unittest.main()

When I run it, I get the error: Error while finding module specification for 'test_file.py' (AttributeError: module 'test_file' has no attribute 'path')

I have been searching all over stack overflow for how to resolve this or define a path. I am new to Windows operating systems and unit testing so I'm very lost on how to resolve this. If you have any insight, it would be much appreciated.

Cassie H.
  • 373
  • 2
  • 7
  • 24
  • 1
    How are you executing this test file ? – amrx May 31 '17 at 18:14
  • Here you go https://stackoverflow.com/questions/21640794/python-os-path-doesnt-exist-attributeerror-module-object-has-no-attribute. – amrx May 31 '17 at 18:19

0 Answers0