How to set screen size by phantomjs in selenium python

How to set phantomJS screen size in selenium using python? Size can be read by JS.

the code is here:

driver = PhantomJS() print driver.get_window_size() # output: {u'width': 400, u'height': 300} driver.set_window_size(1920, 1080) print driver.get_window_size() # output: {u'width': 1920, u'height': 1280} # get screen width and height by js, always 1024 * 768 print driver.execute_script('return window.screen.width') # output: 1024 print driver.execute_script('return window.screen.height') # output: 768 

Get screen size by js, always 1024 * 768.

+5
source share

Source: https://habr.com/ru/post/1268389/


All Articles