How and where to store dynamic result/data using webdriver java



  • I want to know "How and where to store dynamic (Search results) result/data", I am getting the results and not sure what to do next. Also, after saving these results I want to use this in another class (By index I want to compare with other values or .equals). Application url is: http://www.jabong.com/shoes/Puma/?qc=puma shoes&r=2 Below is the sample code, please let me know how to do it. 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 Test1 { public static WebDriver driver = new FirefoxDriver(); static String[] imageLocation = null; public static void main(String []args) throws Exception { driver.get("http://www.jabong.com/shoes/Puma/?qc=puma shoes&r=2"); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); driver.manage().window().maximize(); List<WebElement> listOfOptions = driver.findElements(By.xpath(".//*[@id='content']/section/section/div[5]/div[2]")); for(WebElement listOfOption :listOfOptions ){ System.out.println(listOfOption.getText()); } } }



  • Hello since you are getting the results in the List, you can export them to a file for use in future, or can use them further for comparison or whatever you need since the data is already stored in the List variable. You can see in this sample code here - http://milinpatel17.wordpress.com/2014/07/02/web-page-link-test-using-selenium-webdriver/ that I have stored all the links in a webpage in a List variable and then run the list in a loop to check the http status of each link from the List. Similarly I'll will look for an example of writing the list to a file and update it here! 🙂 Hope this helps you!



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2