import os
import time

from selenium.webdriver.support.select import Select

from Data.parameters import Data
from get_dir import pwd
from reuse_func import GetData


class All_records_download():

    def __init__(self,driver):
        self.driver = driver
        self.filename =''
    def test_download_csv(self):
        self.data = GetData()
        self.p = pwd()
        self.driver.find_element_by_xpath(Data.hyper_link).click()
        self.data.page_loading(self.driver)
        colltype = Select(self.driver.find_element_by_name('collection_type'))
        colltype.select_by_visible_text(' Overall ')
        self.data.page_loading(self.driver)
        self.driver.find_element_by_id(Data.Download).click()
        time.sleep(4)
        self.filename = self.p.get_download_dir() + '/collectionType_all_data.csv'
        time.sleep(2)
        file = os.path.isfile(self.filename)
        os.remove(self.filename)
        return file



[(17, 'reuse_func.GetData', 'GetData', False, 'from reuse_func import GetData\n'), (18, 'get_dir.pwd', 'pwd', False, 'from get_dir import pwd\n'), (25, 'time.sleep', 'time.sleep', False, 'import time\n'), (27, 'time.sleep', 'time.sleep', False, 'import time\n'), (28, 'os.path.isfile', 'os.path.isfile', False, 'import os\n'), (29, 'os.remove', 'os.remove', False, 'import os\n')]