title: how to store webtable in java collection hashmap or hashset or arraylist?
body: <p>In my application on users profile page, user has:</p>
  
  <pre><code>Name: XYZ
  Age: ##
  Address: st.XYZ
  </code></pre>
  
  <p>and so on...</p>
  
  <p>When an element is missing (example age) other row takes its place, so I can't hardcode the <code>xpath</code> of elements. What I want is:</p>
  
  <p>I want to (print) extract entire table data and compare with actual.
  So when I ask for "Name" as key it should give cell value infront of it as value of key.</p>
  
  <p>What I tried:
  I was able to get text of <code>tr</code> tags elements keeping <code>td</code> fixed. But for another user when some row is missing it fails or gives wrong value.</p>
  
  <pre><code>for (int i = 2; i &lt; 58; i++) {
      String actor_name = new WebDriverWait(driver, 30).until(ExpectedConditions
              .elementToBeClickable(By.xpath(first_part+i+part_two))).getText();
      System.out.print("\n"+"S.no. "+(i-1)+" "+actor_name);
      try {
  
  
          driver.findElement(By.xpath(first_part+i+part_two)).click();
          new WebDriverWait(driver, 30).until(ExpectedConditions
                  .elementToBeClickable(By.partialLinkText("bio"))).click();
          //driver.findElement(By.partialLinkText("bio")).click();
  
      } catch (Exception e) {
          // TODO: handle exception
          System.out.println("Not a link");
      }
      Thread.sleep(5000);
  
      System.out.print(" "+driver.findElement(By.xpath("//*[@id='overviewTable']/tbody/tr[3]/td[2]")).getText());
      driver.get("http://www.imdb.com/title/tt2310332/fullcredits?ref_=tt_cl_sm#cast");
  }
  </code></pre>
  
  <p>Above code works fine for top 3 actors on <a href="http://www.imdb.com/title/tt2310332/fullcredits?ref_=tt_cl_sm#cast" rel="nofollow">this</a> page but fails for 4th because that doesn't have one row missing on bio page.</p>
  
  <p>On the bio page there two columns in the table one has attribute other has its value. I want to make a collection with key value pair with <code>key</code> as attribute (value from left column) and its <code>value</code> as value from right column. So that I get the freedom of fetching the values by mentioning the attribute value.</p>
  
  <p>I am using JAVA to write scripts.</p>