Friday, 27 December 2013

Selenium Webdriver - How To get options of Dropdown -Example


WebDriver driver1 = new FirefoxDriver();
driver.navigate().to("http://www.tizag.com/htmlT/htmlselect.php");
WebElement dropdown = driver.findElement(By.xpath("/html/body/table[3]/tbody/tr/td[2]/table/tbody/tr/td/div[4]/select"));
  Select value = new Select(dropdown);
  List<WebElement> options =  value.getOptions();

   for(int i=0;i<options.size();i++)
  {
  String ValueToFind="Colorado -- CO";
  String OptionValue;
  OptionValue=options.get(i).getText();
  if(OptionValue.contains(ValueToFind))
  {
  System.out.print("Option is present ");
  }

  }

6 comments:

  1. I'm struck in upload image/list to my project using selenium. searched in number of site no luck.

    please advise me.

    ReplyDelete
    Replies
    1. Hi Satish,

      Selenium do support file upload ,but not sure which approach you took up for bulk upload so would suggest to share some details if you can.

      Delete
    2. hello priyanka,how to write test cases for selecting dropdown list in ruby using selenium

      Delete
  2. UiPath Training in Bangalore by myTectra is one the best UiPath Training. myTectra is the market leader in providing Robotic Process Automation on UiPath
    ui path training in bangalore

    ReplyDelete
  3. I’m planning to start my blog soon, but I’m a little lost on everything. Would you suggest starting with a free platform like Word Press or go for a paid option? There are so many choices out there that I’m completely confused. Any suggestions? Thanks a lot.
    Best AWS Training in Marathahalli | AWS Training in Marathahalli
    Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai
    AWS Training in Velachery | Best AWS Course in Velachery,Chennai
    Best AWS Training in Chennai | AWS Training Institutes |Chennai,Velachery

    ReplyDelete