0

While trying to take a screenshot of a website

  • in Firefox
  • with width=300 pixels,, height=600 pixels
  • with a specific set of extensions activated (within the default-release profile of Firefox)
  • from a CLI/bash/Python code I am experiencing some difficulties.

Approach I

First I tried the solution in this anwer code, however ws2 variable remains an empty list, which causes the procs[0][0][1] to remain an empty list [], and I do not yet know how to get the window ID of the new application/firefox instance that is/should be started (such that I can substitute it in:

     cmd3 = "xdotool windowsize --sync "+procs[0][0][1]+" "+sys.argv[4]+"% "+sys.argv[5]+"%"
     cmd4 = "xdotool windowmove "+procs[0][0][1]+" "+sys.argv[2]+" "+sys.argv[3]

Approach II

Then I learned Firefox has a built-in method to take a screenshot method to take screenshots, which can be called with:

firefox --browser --profile "/home/name/.mozilla/firefox/hzx2x9en.default-release-1669642876156" -screenshot -window-size 360,640 /home/example.png https://startpagina.nl

Which creates the screenshot of the desired size, however it does not apply the extensions within that profile consistently. I was able to eliminate the "login element" in the top right, as shown in the generated example.png screenshot below:

enter image description here

However, when I remove additional elements, to make the page look like:

enter image description here

The screenshot taken by the cli is not updated accordingly, the same screenshot (without the login icon) is re-created. (I tried rebooting), however the result is still the same.

Question

Hence, I would like to ask: How can I take a screenshot of a website (https://www.startpagina.nl)

  • in Firefox
  • with width=300 pixels,, height=600 pixels
  • with a specific set of extensions activated (within the default-release profile of Firefox)
  • from a CLI/bash/Python code (on Ubuntu) ?

Note

One can probably manage this with Selenium however, I thought it might be possible with less boilerplate code.

a.t.
  • 2,002
  • 3
  • 26
  • 66

0 Answers0