0% found this document useful (0 votes)
24 views2 pages

APICommands 1

The document discusses three Selenium WebDriver methods: getCurrentUrl() retrieves the current page URL, close() closes the current browser window, and quit() closes all browser windows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

APICommands 1

The document discusses three Selenium WebDriver methods: getCurrentUrl() retrieves the current page URL, close() closes the current browser window, and quit() closes all browser windows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

• getCurrentUrl() - Used to retrieve the URL of the current web page

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Demo {

public static void main(String[] args) {

WebDriver driver = new FirefoxDriver();

driver.get("https://iamsandesh23.github.io/selenium.github.io/");

driver.manage().window().maximize();

driver.findElement(By.linkText("compendiumdev")).click();

String str = driver.getCurrentUrl();

System.out.println(str);
}
}

• close() - Used to close the current Browser window

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Demo {

public static void main(String[] args) {

WebDriver driver = new FirefoxDriver();

driver.get("http://www.msn.com");

driver.manage().window().maximize();

driver.close();
}
}
• quit() - Used to close all the Browser windows (i.e. All the browser
windows, including child windows, will be closed)
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Demo {

public static void main(String[] args) {

WebDriver driver = new FirefoxDriver();

driver.get("https://iamsandesh23.github.io/selenium.github.io/");

driver.manage().window().maximize();

driver.findElement(By.linkText("Blogger")).click();

driver.quit();
}
}

You might also like