JordanBelf
JordanBelf

Reputation: 3348

'window_maximize()' is not an attribute of WebDriver in Selenium

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!

Upvotes: 0

Views: 3843

Answers (2)

dev_il
dev_il

Reputation: 326

You can use browser.maximize_window(). I think the problem was in the wrong function name.

Upvotes: 3

JordanBelf
JordanBelf

Reputation: 3348

OK, after much looking for how to use window_maximize I found out I can use browser.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?

Upvotes: 0

Related Questions