Untitled
unknown
plain_text
2 years ago
946 B
10
Indexable
public class AutosuggestionTest {
public static void main(String[] args) throws InterruptedException
{
WebDriver driver= new EdgeDriver();
driver.get("https://www.flipkart.com/");
driver.manage().window().maximize();
driver.findElement(By.xpath("//span[text()='✕']")).click();
driver.findElement(By.xpath("//input[@title=\"Search for Products, Brands and More\"]")).sendKeys("iphone");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
java.util.List<WebElement> autosugglist = driver.findElements(By.xpath("//li[@class=\"_3D0G9a\"]"));
if (autosugglist.size()>=4)
{
String thirdelement=autosugglist.get(3).getText();
System.out.println("Autosuggestion third elements" + thirdelement);
}
/*(for (WebElement listed : autosugglist)
{
if (listed.getText().contains("iphone 15"))
{
listed.click();*/
driver.close();
}
{
Editor is loading...
Leave a Comment