Commit bce64ad6 authored by Qazi Zain's avatar Qazi Zain

Filter, and pagination code is added

parent 41bf91e4
...@@ -50,4 +50,5 @@ test.txt ...@@ -50,4 +50,5 @@ test.txt
allure-results allure-results
testng.xml
package Streams;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Filtering {
public static void main(String[] args) {
ChromeOptions ssl= new ChromeOptions();
ssl.setAcceptInsecureCerts(true);
WebDriver obj = new ChromeDriver(ssl);
obj.get("https://www.daraz.pk/#?");
WebElement searchBox = obj.findElement(By.cssSelector("input[placeholder='Search in Daraz']"));
searchBox.sendKeys("gents chappal");
WebDriverWait wait = new WebDriverWait(obj, Duration.ofSeconds(10));
List<WebElement> rows = wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//div[@class='suggest-list--3Tm8']//a")));
List<String> results= new ArrayList<>();
//System.out.println(rows);
for(WebElement e: rows)
{
results.add(e.getText());
}
for(int i =0; i<results.size();i++)
{
System.out.println("The item of filter: "+results.get(i));
}
}
}
package Streams;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Pagenation
{
public static void main(String[] args)
{
WebDriver obj = new ChromeDriver();
obj.get("https://datatables.net/");
WebElement searchBox = obj.findElement(By.xpath("//div[@class='dt-search']//input"));
searchBox.sendKeys("london");
List<String> lists = new ArrayList<>();
boolean button = true;
while (button)
{
List<WebElement> items = obj.findElements(By.xpath("//div[@class='dt-layout-row dt-layout-table']//tbody/tr"));
for (WebElement e : items)
{
lists.add(e.getText());
}
try
{
WebElement nextButton = obj.findElement(By.xpath("//button[@class='dt-paging-button next']"));
if (nextButton.isEnabled())
{
nextButton.click();
}
else
{
button = false;
}
}
catch (Exception e)
{
button = false;
}
}
for (String value : lists)
{
System.out.println("Value fetched: " + value);
}
obj.quit();
}
}
\ No newline at end of file
...@@ -2,14 +2,7 @@ ...@@ -2,14 +2,7 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite"> <suite name="All Test Suite">
<test verbose="2" preserve-order="true" <test verbose="2" preserve-order="true"
name="/Users/zain/Documents/SeleniumTraining/src/main/java/POM_Structure_code"> name="/Users/zain/Documents/SeleniumTraining/src/main/java/NisumWebTest/Cucumber">
<classes> <classes/>
<class name="POM_Structure_code.TestClasses.LoginTest">
<methods>
<include name="LoginTest"/>
<include name="checked"/>
</methods>
</class>
</classes>
</test> </test>
</suite> </suite>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment