1#coding=utf-8
2import time
3from selenium import webdriver
4from selenium.webdriver.chrome.options import Options
5
6def test_fullpage_screenshot(self):
7 chrome_options = Options()
8 chrome_options.add_argument('--headless')
9 chrome_options.add_argument('--start-maximized')
10 driver = webdriver.Chrome(chrome_options=chrome_options)
11 driver.get("yoururlxxx")
12 time.sleep(2)
13
14 #the element with longest height on page
15 ele=driver.find_element("xpath", '//div[@class="react-grid-layout layout"]')
16 total_height = ele.size["height"]+1000
17
18 driver.set_window_size(1920, total_height) #the trick
19 time.sleep(2)
20 driver.save_screenshot("screenshot1.png")
21 driver.quit()
22
23if __name__ == "__main__":
24 test_fullpage_screenshot()