You are on page 1of 2

URI identifies a resource and differentiates it from others by using a name,

location, or both. URL identifies the web address or location of a unique resource.
URI contains components like a scheme, authority, path, and query. URL has similar
components to a URI, but its authority consists of a domain name and port.

The main difference between a URL and a URI is that a URL specifies the location of
a resource on the internet, while a URI can be used to identify any type of
resource, not just those on the internet. URI is usually used in XML, tag library
files, and other files, such as JSTL and XSTL.

2. What is the difference between path parameter and query parameter in API?

query parameters are used to sort/filter resources. On the other hand, path
parameters are used to identify a specific resource or resources.

A path parameter normally refers to a resource by its unique identifier. For


example, if you want to refer to a user with a userId of "20", the request URL
would be /users/20. It is also possible for a URL to contain multiple path
parameters,
for example: /client/{clientId}/department/{departmentId}/employees
for query parameter will use ? mark and for path paramert will use the /

3. how do you configure invironmnet variable name in postman?

we have a globla variable


local variable
collection level vairable
Select Add a new variable, and enter a name for the variable.
Select a Type for the new variable.
Add an Initial Value, and if you choose, a Current Value.
Select Save to confirm your changes.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.Set;

public class WindowHandlesExample {


public static void main(String[] args) {
// Set the path to the chromedriver executable
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");

// Initialize ChromeDriver
WebDriver driver = new ChromeDriver();

// Open the first window


driver.get("https://www.example.com");

// Get the handle of the first window


String mainWindowHandle = driver.getWindowHandle();

// Open a new window


((ChromeDriver) driver).executeScript("window.open()");

// Get all window handles


Set<String> allWindowHandles = driver.getWindowHandles();

// Switch to the new window


for (String handle : allWindowHandles) {
if (!handle.equals(mainWindowHandle)) {
driver.switchTo().window(handle);
break;
}
}

driver.get("https://www.example2.com");

// Get the title of the first window


String firstWindowTitle =
driver.switchTo().window(mainWindowHandle).getTitle();
System.out.println("Title of the first window: " + firstWindowTitle);

// Get the title of the second window


String secondWindowTitle =
driver.switchTo().window(mainWindowHandle).getTitle();
System.out.println("Title of the second window: " + secondWindowTitle);

// Close the browser


driver.quit();
}
}

You might also like