Quality Testing

Quality is delighting customers

How to minimize and maximize a window using selenium tool?

How to minimize and maximize a window using selenium tool? This is the question I was faced in an interview last week.

Appriciate all your valubel answers.

~Jelissa

Views: 976

Reply to This

Replies to This Discussion

Hi there!

selenium.windowMaximize(); and I reckon the same with minimize :)
I agree with Kateryna's reply. Thanks.

Most testing company use these types of questions while hiring people, Selenium supports a built-in function to maximize the window, however, the selenium doesn't support any built-in function to minimize the browser window.

here is the sample script for the same: 

package javaAutomation;

import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Test {

public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "c://selenium//chromedriver.exe");
WebDriver driver;
driver = new ChromeDriver();
driver.get("https://www.google.com");
driver.manage().window().maximize();
Thread.sleep(5000);
driver.manage().window().setPosition(new Point(-2000, 0));
Thread.sleep(5000);
driver.close();
}
}

However, we will need to import the Point class from the selenium. 


Thanks

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2021   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service