I am using Selenium and for this task I need to maximize the browser after the page is loaded, the problem is that I am getting the following error and can’t seem to understand how to solve it.
AttributeError: 'WebDriver' object has no attribute 'window_maximize'
Here is the code I am testing
from pyvirtualdisplay import Display
from ftplib import FTP
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.common.keys import Keys
#initialize HIDDEN display
display = Display(visible=0, size=(1366, 768))
display.start()
browser = webdriver.Firefox()
browser.get('http://youtube.com/')
browser.window_maximize();
...
Isn’t window_maximize an attribute of the browser?
I am using python and Selenium Server 2.28
Any tip much appreciated!
OK, after much looking for how to use
window_maximizeI found out I can usebrowser.set_window_size(800, 600)instead.I tested and it works fine. It is important to set the browser to
browser.set_window_position(0, 0)The answer was found here How to maximize a browser window using the Python bindings for Selenium 2-WebDriver?