Here is a quick script to show how you could capture images to do some responsive testing. The test is super quick and you end up with 4 images that you can look at to see if things are put on the page correctly.
I chose some break points that made sense to me. I think if you are using bootstrap your breakpoints might be different. Just change the width to whatever you want to check.
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
driver = None
def checkit(w,filename):
driver.set_window_size(w,HEIGHT)
driver.get("https://getbootstrap.com/docs/4.0/examples/blog/")
driver.save_screenshot(filename)
try:
cpath = "e:\\projects\\headless\\chromedriver.exe"
driver = webdriver.Chrome(cpath)
HEIGHT = 768
checkit(600,"test0.png")
checkit(900,"test1.png")
checkit(1200,"test2.png")
checkit(1800,"test3.png")
finally:
if driver is not None:
driver.quit()
`
If you have read the other posts I have done this code is slightly different.
I made a function called checkit to make the code more readable.
Top comments (1)
Thats really great