Home > Mobile >  How to bring browser to front and maximize using Selenium Python
How to bring browser to front and maximize using Selenium Python

Time:04-28

I am working on automating a section of data entry using a mixture of Selenium and Pyautogui.

I have the manual automated part down using the module Pyautogui but I need to bring the browser to the front so the mouse and keyboard can interact with the browser.

All the solutions I've tried maximizes the window but it stays in the background.

CodePudding user response:

Try the below

from selenium import webdriver

driver = webdriver.Chrome()

driver.switch_to.window(driver.current_window_handle)

CodePudding user response:

To bring the browser to frontground and maximize using Selenium and Python you can use the following set of lines:

driver.execute_script("window.focus();")
driver.maximize_window()
  • Related