1

Using Selenium with Python, I am trying to take screenshot and saving them in a folder which has date and timestamp but nothing is getting saved in the folder. This is the code snippet:

Folder creation activity:

path = 'C:\\Users\\name\\Desktop\\ADF'
DateString = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
os.chdir(path)
NewFolder = 'PBI_' + DateString
os.makedirs(NewFolder)

To save the screenshot, I am using:

driver.save_screenshot(os.path.join(os.path.dirname(os.path.realpath(__file__)), NewFolder,'Before_Authentication.png'))

Folder name "NewFolder" is getting created successfully but no screenshot is present here.

0

1 Answer 1

3
import datetime
path = 'C:\\Users\\name\\Desktop\\ADF'
DateString = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
os.chdir(path)
NewFolder = 'PBI_' + DateString
os.makedirs(NewFolder)
driver.save_screenshot(NewFolder+'/foo.png')

Seems to create the file just fine just append the file name to the new folder.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much Arun, it worked !!!!
No problem accept the answer if it helped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.