Search code examples
maximize-windowseleniumbase

Seleniumbase maximize window


I have been using Selenium for several years and am reasonably proficient. I have recently run into various bot/scraper detectors that have shut me out. It appears that seleniumbase has what it takes to avoid detection. However, i am unable to get the window (using chrome) to open and fill the entire screen - open maximized. In selenium this is relatively simple, but i have been unsuccessful in seleniumbase. I am running python and need to find the command(s) that will open the window in a maximized state. The documentation is quiet on this point and the code samples also do not seem to provide a model. I have used the settings file to get close, but it does not align itself properly in the corners. I know there is a way to do better.

Thanks in advance.


Solution

  • Window maximization is achieved in SeleniumBase after the browser is launched.

    Use driver.maximize_window() with the SeleniumBase Driver() format. Example:

    from seleniumbase import Driver
    
    driver = Driver(uc=True)
    try:
        driver.maximize_window()
        driver.open("https://seleniumbase.io/demo_page")
        driver.sleep(2)
    finally:
        driver.quit()