Wednesday, January 14, 2015

Selenium script to get list of values

//code to get list of values

package Ecomm_selenium;
import java.util.List;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

//Getting list of webElements
public class Login {

                /**
                * @param args
                */
                public static void main(String[] args) {
                                // TODO Auto-generated method stub
                               
                                String site = "http://www.flipkart.com/";
                    String paths = ".//*[@id='fk-mainbody-id']/div/div[2]";                            
                    //String
                               
                                WebDriver d = new FirefoxDriver();
                                d.get(site);
                                List<WebElement> colu_vals = d.findElements(By.className("goquickly-list"));
                                java.util.Iterator<WebElement> i = colu_vals.iterator();
                                while(i.hasNext())
                                {
                                                WebElement value = i.next();
                                                System.out.println(value.getText());
                                               
                                }
                               
                               
                }

}

No comments:

Post a Comment