Webdriver Screenshot

后端 未结 12 874
南方客
南方客 2020-11-30 00:57

When taking a screenshot using Selenium Webdriver on windows with python, the screenshot is saved directly to the path of the program, is there a way to save the .png file t

12条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 01:31

    This will take screenshot and place it in a directory of a chosen name.

    import os
    driver.save_screenshot(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'NameOfScreenShotDirectory', 'PutFileNameHere'))
    

提交回复
热议问题