Posts

Showing posts from April, 2022

How to check ascending and descending order with pagination?

 package Admin; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.testng.Assert; import org.testng.annotations.Test; import BaseInit.BaseInit; import MyMethods.MyLoginMethods; public class Sorting extends BaseInit { @Test public static void sortingtest() throws InterruptedException { // Login to Admin Panel MyLoginMethods.AdminLogin(datap.getProperty("email"), datap.getProperty("Pass")); driver.get(sitedata.getProperty("confiProURL")); Thread.sleep(2000); ArrayList<String> ActualList = new ArrayList<String>(); ArrayList<String> sortedList = new ArrayList<String>(); String[] pageItem = epresent("pageItem_className").getText().split(" "); String TotalPage = pageItem[3].trim(); System.out.println("Items per Page is- " + TotalPage); int PagePerItem = Integer.parse...

How to handle new tab in selenium?

 package newTab; import java.util.ArrayList; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.testng.annotations.Test; import BaseInit.BaseInit; public class newTab extends BaseInit { @Test public static void openNewTab() throws InterruptedException { driver.get("https://www.abc.com/"); Thread.sleep(2000); driver.findElement(By.xpath("//*[@id=\"mm-0\"]/div/header/div/div/div/div[1]/div[2]/div/a")).sendKeys(Keys.CONTROL, Keys.ENTER); Thread.sleep(2000); ArrayList<String> tabs = new ArrayList<String>(driver.getWindowHandles()); driver.switchTo().window(tabs.get(1)); Thread.sleep(2000); driver.switchTo().window(tabs.get(0)); } }