等待Python+;硒+;火狐
我想在文件下载完成后立即关闭浏览器。我有下面的代码,但它没有关闭浏览器。我一定是哪里错了。请帮帮我等待Python+;硒+;火狐,python,python-3.x,selenium,firefox,Python,Python 3.x,Selenium,Firefox,我想在文件下载完成后立即关闭浏览器。我有下面的代码,但它没有关闭浏览器。我一定是哪里错了。请帮帮我 driver.find_element_by_link_text("[Comma-Delimited Text (CSV)]").click() while True: if os.path.isfile('C:\\Python34\\*.part'): time.sleep(10) elif os.path.isfile('C:\\Python34\\*.csv'
driver.find_element_by_link_text("[Comma-Delimited Text (CSV)]").click()
while True:
if os.path.isfile('C:\\Python34\\*.part'):
time.sleep(10)
elif os.path.isfile('C:\\Python34\\*.csv'):
break
else:
time.sleep(10)
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
不支持导致循环永不退出的全局样式路径定义
您需要使用glob.glob()
或fnmatch
:
def downloader() :
print("File Download Started.......")
sleep(60)
while True:
file = glob.glob(BASE_FILE_DIR+'*.zip.part')
if file:
print("Download Pending.......")
sleep(60)
continue
else:
print('File Downloaded')
break
这正是我想要的,当文件下载在几秒钟到几分钟之间时,它非常有用。非常感谢你!