• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

  • Home
  • Interview Questions
  • Java
  • Java Programs
  • Selenium
  • Selenium Programs
  • Manual Testing
  • Test Cases
  • Difference
  • Tools
  • SQL
  • Contact Us
  • Search
SoftwareTestingo » Selenium » Selenium Programs » How to Print Auto Suggestion List In Java Selenium Example Program?

How to Print Auto Suggestion List In Java Selenium Example Program?

Last Updated on: November 5, 2018 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • How to Print Auto Suggestion List In Java Selenium Example Program?

How to Print Auto Suggestion List In Java Selenium Example Program?

package com.selenium.basics;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Autosuggestionlist 
{
   public static void main(String[] args) throws InterruptedException
   {
      System.setProperty("webdriver.chrome.driver", "./driver/chromedriver.exe");
      WebDriver driver=new FirefoxDriver();
      driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
      driver.get("http://www.flipkart.com/");
      driver.findElement(By.name("q")).sendKeys("mobile");
      Thread.sleep(5000);
      String xp="//ul/li//a[contains(text(),'mobile')]";
      List<WebElement> allMobiles = driver.findElements(By.xpath(xp));
      for(WebElement mobile:allMobiles)
      {
         System.out.println(mobile.getText());
      }
      driver.quit();
   }
}
Read Also: Capture Screenshot Different Name Using TestNg

    Filed Under: Selenium Programs

    Reader Interactions

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Categories

    Copyright © 2022 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy ~ Testing Careers