Opening ChromeDriver in fullscreen, selenium and python

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-04 14:56:11

问题


I'm attempting to open my ChromeDriver in full screen. I've tried everything possible and can't seem to find a solution for it. After searching throughout google and stackoverflow it seems many people have had the same issue, this is for mac os x. I thought that doing the (command, shift, f) would work but it doesn't. Does anyone have a solution?

     from selenium import webdriver
     from selenium.webdriver.common.keys import Keys
     import time
     urls = [x,y,z]
     driver = webdriver.Chrome() #Would like chrome to start in fullscreen
     driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND, Keys.SHIFT, 'f') #not sure why this doesn't work.
     driver.get("https://example.com") 

回答1:


Launch chrome with argument "--kiosk" using chrome_options.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chromeOptions = Options()
chromeOptions.add_argument("--kiosk")
driver = webdriver.Chrome(chrome_options=chromeOptions) #Would like chrome to start in fullscreen
driver.get("https://example.com")
driver.quit() 


来源:https://stackoverflow.com/questions/33811752/opening-chromedriver-in-fullscreen-selenium-and-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!