Z
Z
Zelyoniy2021-02-03 23:03:13
Python
Zelyoniy, 2021-02-03 23:03:13

How to concatenate date and screenshot name?

The screenshot is not taken or saved, there are no errors in the console:

browser = webdriver.Chrome(executable_path=r'C:\chromedriver.exe')

(какой-то код)

get_date = str(time.strftime('%d.%m.%Y %H:%M:%S', time.localtime(time.time())))
screenshot_name = "C:/UI_tests/Screenshots/" + get_date + "-screenshot.png"
screenshot = browser.get_screenshot_as_file(screenshot_name)


The screenshot is taken and saved in the desired directory:
browser = webdriver.Chrome(executable_path=r'C:\chromedriver.exe')
(какой-то код)
screenshot = browser.get_screenshot_as_file("C:/UI_tests/Screenshots/-screenshot.png")


How is it possible to concatenate date with save path and screenshot name?
In the "browser.get_screenshot_as_file" attributes, as I understand it, a string is expected, which is what screenshot_name is, if it is checked through type (). Then what is the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-02-03
@Zelyony

Character not supported :in file name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question