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%20shoes&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.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

List<WebElement> listOfOptions = driver.findElements(By.xpath(".//*[@id='content']/section/section/div[5]/div[2]"));
for(WebElement listOfOption :listOfOptions ){

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!

  • Could you tell me how please (Sample code/Logic, etc), because spent lot of time on this but didn't get success. – QA4it Sep 14 '14 at 4:37
  • 1
    Hello check the update in the answer above! Hope it will help you – IAmMilinPatel Sep 14 '14 at 5:31
  • It's worked.. :) – QA4it Sep 14 '14 at 17:15
  • 1
    Great i'm glad i could help! :) – IAmMilinPatel Sep 15 '14 at 2:18
  • 1
    How to access these values in another class? (I want to compare these values in another class variable values). – QA4it Sep 15 '14 at 6:24

I found this really simple code to write output to file. You can find it here - http://www.mkyong.com/java/how-to-write-to-file-in-java-bufferedwriter-example/

You can customize the code to fit your need and write the list values to file by placing the bw.write() part withing a loop.

  • This is very useful :).. Voted up for this. – QA4it Sep 16 '14 at 12:10
  • 1
    Always glad to help fellow testers! And ya, do write about the accessing of values in another classes. I'd really like to learn about it! – IAmMilinPatel Sep 16 '14 at 12:12
  • I am working on it, but not getting the particular solution. – QA4it Sep 16 '14 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.