Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to maximize the browser window.
Selenium Java
driver.manage().window().[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using minimize() instead of maximize()
Using setSize() without parameters
✗ Incorrect
The maximize() method maximizes the browser window to full screen.
2fill in blank
mediumComplete the code to get the current size of the browser window.
Selenium Java
Dimension size = driver.manage().window().[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using setSize() instead of getSize()
Using getPosition() which returns window location
✗ Incorrect
The getSize() method returns the current size of the browser window as a Dimension object.
3fill in blank
hardFix the error in setting the browser window size to 1024x768.
Selenium Java
driver.manage().window().setSize(new Dimension([1], 768));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using height instead of width as first parameter
Using 768 as width instead of height
✗ Incorrect
The Dimension constructor takes width first, so 1024 is the width.
4fill in blank
hardFill both blanks to set the browser window size to 800x600.
Selenium Java
driver.manage().window().setSize(new Dimension([1], [2]));
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping width and height values
Using incorrect numbers like 1024 or 768
✗ Incorrect
The Dimension constructor takes width first (800), then height (600).
5fill in blank
hardFill all three blanks to maximize the window, get its size, and print width.
Selenium Java
driver.manage().window().[1](); Dimension size = driver.manage().window().[2](); System.out.println(size.[3]());
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using getHeight instead of getWidth
Forgetting to maximize before getting size
✗ Incorrect
First, maximize the window with maximize(). Then get the size with getSize(). Finally, print the width using getWidth method of Dimension.