I am currently trying to code a basic smartmirror for my coding II class in high school with python. One thing I'm trying to do is open new tabs in full screen (using chrome). I currently have it so I can open url's, but I am not getting them in full screen. Any ideas on code I can use to open chrome in full screen?
Asked
Active
Viewed 2.0k times
3 Answers
12
If you're using selenium
, just code like below:
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://google.com')
driver.maximize_window()
-
1Fullscreen is different than maximized. That is why I down voted. – Charlie Jun 26 '21 at 18:42
-
Still, this is exactly what I've been looking for! – Andreas L. Aug 23 '22 at 20:03
1
As suggested, selenium is a good way to accomplish your task.
In order to have it full-screen and not only maximized I would use:
chrome_options.add_argument("--start-fullscreen");
or
chrome_options.add_argument("--kiosk");
First option emulates the F11 pressure and you can exit pressing F11. The second one turns your chrome in "kiosk" mode and you can exit pressing ALT+F4.
Other interesting flags are:
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
Those will remove the top bar exposed by the chrome driver saying it is a dev chrome version.
The complete script is:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_experimental_option("useAutomationExtension", False)
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
# chrome_options.add_argument("--start-fullscreen");
chrome_options.add_argument("--kiosk");
driver = webdriver.Chrome(executable_path=rel("path/to/chromedriver"),
chrome_options=chrome_options)
driver.get('https://www.google.com')
"path/to/chromedriver"
should point to the chrome driver compatible with your chrome version downloaded from here

Lorenzo Sciuto
- 1,655
- 3
- 27
- 57
0
your code is nearly perfect. However, the only mistake is that your sequence is incorrect. Please refer to the updated code below.
from selenium import webdriver
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://google.com')

Biplab
- 71
- 1
- 7