pythonseleniumwebdriverselenium-chromedriversplinter

How is a unique id being added to my (python) Splinter screenshot filenames?


I'm using Splinter (in Chrome browser) to take screenshots of website pages. I am naming the files exactly as I want them but unique strings are being added to the end of my filenames (eg, "filename2k3j39.png"). I haven't found anything in the Splinter or Selenium documentation that indicates that these are added. What part of the program is adding the Unique Ids? Windows 10, Chromedriver, Selenium, Splinter?

I've checked my Chrome settings and don't see anything. Files are saved as a PNG so it's not a PDF setting.

from splinter import Browser
executable_path = {'executable_path':r'C:\Users\me\chromedriver.exe'}
browser = Browser('chrome', **executable_path)

screenshot_path = browser.screenshot('C:/Home/Progress/me/screen shots/' + my_var + '/web/www_' + name + ' (' + now.strftime("%Y-%m-%d") + ')', full=True)

The result is www_Name (1-1-2000)2k3j39.png instead of www_Name (1-1-2000).png


Solution

  • So, I worked out what was happening here .... by debugging the splinter library I could see that it doesn't match the document. The library takes the filename, uses that as a prefix to the python function to create a temporary file and adds the undocumented parameter suffix (which defaults to png). It then returns the filename from the function.

    So, I modified my code to: filename = tdir + datetime.date.today().strftime('%Y-%b-%d-image.png') actualName = element.screenshot(filename, suffix='.png', full=False) move(actualName, filename)

    I also had issues with the python os libraries for rename and remove on windows, hence I am using shutil.move