Created
November 30, 2021 16:50
-
-
Save muditlambda/d2f759be4dd9f1af3e753020a6ecf4e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package LambdaTest; | |
| import org.junit.AfterClass; | |
| import org.junit.BeforeClass; | |
| import org.junit.Test; | |
| import org.openqa.selenium.remote.DesiredCapabilities; | |
| import org.openqa.selenium.remote.RemoteWebDriver; | |
| import java.net.MalformedURLException; | |
| import java.net.URL; | |
| class MinimizeBrowserWindow { | |
| public String username = "YOUR USERNAME"; | |
| public String accesskey = "YOUR ACCESSKEY"; | |
| public static RemoteWebDriver driver = null; | |
| public String gridURL = "@hub.lambdatest.com/wd/hub"; | |
| @BeforeClass | |
| public void setUp() throws Exception { | |
| DesiredCapabilities capabilities = new DesiredCapabilities(); | |
| capabilities.setCapability("browserName", "chrome"); | |
| capabilities.setCapability("version", "95.0"); | |
| capabilities.setCapability("platform", "win10"); // If this cap isn't specified, it will just get the any available one | |
| capabilities.setCapability("build", "MinimizeBrowserWindow"); | |
| capabilities.setCapability("name", "MinimizeBrowserWindowUsingSelenium"); | |
| try { | |
| driver = new RemoteWebDriver(new URL("https://" + username + ":" + accesskey + gridURL), capabilities); | |
| } catch (MalformedURLException e) { | |
| System.out.println("Invalid grid URL"); | |
| } catch (Exception e) { | |
| System.out.println(e.getMessage()); | |
| } | |
| } | |
| @Test | |
| public void minimizeBrowserWindow() { | |
| try { | |
| System.out.println("Logging into Selenium Playground"); | |
| driver.get("http://labs.lambdatest.com/selenium-playground/"); | |
| driver.manage().window().minimize(); | |
| System.out.println("Minimized the browser window"); | |
| String title=driver.getTitle(); | |
| System.out.println("The title of web page is:"+title); | |
| } catch (Exception e) { | |
| } | |
| } | |
| @AfterClass | |
| public void closeBrowser() { | |
| driver.close(); | |
| System.out.println("Closing the browser"); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment