Selenium Python_Using JetBrain_FileNotFoundError: [Errno 2] No such file or directory: 'C://Python34//Scripts//pythondata.xlsx'
Question: I trying to perform the data driven testing for `selenium python` but each
time i'm trying to execute i'm facing **Error** 2

    
    
    No such file found 
    

can some one tell me whats wrong with following code

and what file format Selenium Python Support? Is **`.xlsx or .csv`** and do we
need to save excel file in any specific 97-2000 format? or normal format will
work

Sample Code

    
    
    class fblogin(unittest.TestCase):
        def setUp(self):
            self.driver=webdriver.Firefox()
            self.driver.get("URL")
            self.driver.maximize_window()
    
        def test_fblogin(self):
            driver=self.driver
            wb=xlrd.open_workbook("C://Python34//Scripts//pythondata.xlsx")
            sheetname = wb.sheet_names()
            sh1 = wb.sheet_by_index(0)
            i=0
            while (i<2):
                rownum=(i)
            rows = sh1.row_values(rownum)
            UserName = driver.find_element_by_id('UserName')
            driver.find_element_by_id('UserName').send_keys(rows[0, 1])
            driver.implicitly_wait(10)
            print("The Gbouser name [" + rows[0, 1] + "] is entered")
            Password = driver.find_element_by_id('Password')
            driver.find_element_by_id('Password').send_keys(rows[1, 1])
            print("The Password [" + rows[1, 1] + "] is entered")
            driver.implicitly_wait(10)
            driver.back()
            i=i+1
            Login = driver.find_element_by_name('Login').click()
            driver.implicitly_wait(10)
    
        def tearDown(self):
            self.driver.quit()
    
    if __name__ == "__main__":
        unittest.main()
    


Answer: It means there is no `pythondata.xlsx` in `C://Python34//Scripts`.

You can use `os.path.exists` function to check if it exists:

    
    
    import os.path
    os.path.exists(file_path)
    # update file_path with your own path
    

This returns True for both files and directories.

