有没有一种使用 python selenium WebDriver 来最大化 chrome 浏览器窗口的方法?
注意: 我使用的是 Chrome Driver 23.0 任何解决方案都将不胜感激!
Try this:
driver.manage().window().maximize();
You could use ChromeOptions and set suitable argument:
options = ChromeOptions() options.add_argument("--start-maximized") driver = ChromeDriver(options)
Based on what Janek answered, this worked for me (Linux):
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument("--start-maximized") driver = webdriver.Chrome(chrome_options=options)
Nothing worked for me except:
driver.set_window_size(1024, 600) driver.maximize_window()
I found this by inspecting selenium/webdriver/remote/webdriver.py. I've never found any useful documentation, but reading the code has been marginally effective.
For MAC or Linux:
ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--kiosk"); driver = new ChromeDriver(chromeOptions);
For Windows:
ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.addArguments("--start-maximized"); driver = new ChromeDriver(chromeOptions);
Try
ChromeOptions options = new ChromeOptions(); options.addArguments("--start-fullscreen");
I do the following:
from selenium import webdriver browser = webdriver.Chrome('C:\chromedriver.exe') browser.maximize_window()
This works for me, with Mac OS Sierra using Python,
options = webdriver.ChromeOptions() options.add_argument("--kiosk") driver = webdriver.Chrome(chrome_options=options)
try this, tested on windows platform and it works fine :
from selenium import webdriver browser = webdriver.Chrome('C:\\Users\\yeivic\\Downloads\\chromedriver') browser.fullscreen_window() browser.get('http://google.com/')
this works for me
driver.maximize_window() driver.get(url)