Wrap export in try: finally:

This commit is contained in:
Tanner Collin 2023-05-08 21:15:39 +00:00
parent c693d30394
commit 1d5f63f86d

View File

@ -12,7 +12,10 @@ chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('start-maximized')
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome(service=ser, options=chrome_options)
try:
driver.get('https://sensors.dns.t0.vc')
time.sleep(3)
@ -45,6 +48,9 @@ for graph in graphs:
with open('/home/tanner/sensors/export/data/{}.png'.format(graph), 'wb') as f:
f.write(element.screenshot_as_png)
finally:
driver.close()
driver.quit()
print('done.')