简体   繁体   English

如何在python中使用phantomjs和selenium webdriver设置窗口大小

[英]How to set window size using phantomjs and selenium webdriver in python

I'm trying to get a full sized browser screenshot with phantomjs driven by python webdriver . 我正在尝试用python webdriver驱动的phantomjs获取全尺寸的浏览器屏幕截图。 right now my screenshot is measured at 927 x 870, I'd like to reset it. 现在我的截图是在927 x 870测​​量的,我想重置它。 I have tried: 我试过了:

driver.manage().window().setSize(new Dimension(1400,1000))

based on this source , but this is giving syntax errors. 基于此源 ,但这会产生语法错误。

How can I do this? 我怎样才能做到这一点?

Because that's Java. 因为那是Java。 Python's documentation is here . Python的文档就在这里

There's a method called set_window_size , which is defined here : 有一个名为set_window_size的方法, 在这里定义:

driver.set_window_size(1400,1000)

Further reading: How to get window size, resize or maximize window using Selenium WebDriver 进一步阅读: 如何使用Selenium WebDriver获取窗口大小,调整窗口大小或最大化窗口

For Java, the Dimension import has to be: 对于Java,Dimension导入必须是:

import org.openqa.selenium.Dimension;

and it won't give syntax errors 它不会给出语法错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用selenium和python在phantomjs中设置cookie? - How to set cookies in phantomjs using selenium with python? 无法使用python和selenium连接到phantomJs webdriver - Trouble connecting to phantomJs webdriver using python and selenium 如何设置硒窗口的大小? (在python中,在Mac上,使用chromedriver) - How to set the size of the selenium window? (in python, on Mac, using chromedriver) 如何在 Selenium Chrome Python 中设置窗口大小 - How to set window size in Selenium Chrome Python 在phantomjs中使用代理(Selenium WebDriver) - Using a proxy with phantomjs (selenium webdriver) 无法使用phantomjs python单击Selenium Webdriver中的元素 - unnable to click element in selenium webdriver using phantomjs python 如何使用 Selenium 2-WebDriver 的 Python 绑定最大化浏览器窗口? - How to maximize a browser window using the Python bindings for Selenium 2-WebDriver? 如何使用 Python、Selenium Webdriver 和 Chromedriver 在 Jenkins 中最大化窗口? - How to maximize window in Jenkins using Python, Selenium Webdriver and Chromedriver? 如何使用python的Selenium WebDriver在浏览器上打开一个新的window? - How to open a new window on a browser using Selenium WebDriver for python? 如何使用Selenium在PhantomJS中设置浏览器首选项 - How to set browser preference in PhantomJS using Selenium
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM