Looping through a Table with separate colums and clicking on an item within it

Any advise on how to use Selenium-webdriver with Java (using Eclipse and Cucumber plugin).

UPDATE: My first attempt to code gives me this:

//Scenario 2: Verify on clicking the delete button for an existing customer @Given("^I am on the Hotel booking form with saved customers$") public void I_am_on_the_Hotel_booking_form_with_saved_customers() throws Throwable < //Validate if customers records exist in the table. Listrows = driver.findElements(By.xpath(".//*[@id='bookings']//div[@id]")); java.util.Iterator i = rows.iterator(); while(i.hasNext()) < WebElement row = i.next(); System.out.println(row.getText()); >> @When("^valid customers data is being displayed$") public void valid_customers_data_is_being_displayed() throws Throwable < // Write code here that finds and lists all the rows in a table WebElement dynamicDivs = driver.findElement(By.xpath(".//*[@id='bookings']")); Listrows = dynamicDivs.findElements(By.tagName("p")); java.util.Iterator i = rows.iterator(); while(i.hasNext()) < WebElement row = i.next(); System.out.println(row.getText()); >> @When("^I click the delete button$") public void i_click_the_delete_button() throws Throwable < // Write code to delete a specific customer in a row given the firstname = "Tim" and price = "999.99" WebElement pricenumber = driver.findElement(By.className("col-md-1")); //Listrows1 = classnames.findElements(By.tagName("p")); java.util.Iterator i = rows1.iterator(); while(i.hasNext()) < WebElement row1 = i.next(); System.out.println(row1.getText()); string firstnames = driver.findElement(By.className("col-md-2")); System.out.println(firstnames.getText()); if (row1.getText() == "999.99" && firstnames == "Tim" ) < driver.findElement(By.className("col-md-1").cssSelector(".col-md-1>input")).click(); > //Assert that row has been deleted. > > @Then("^I should see the customer details on the last row been deleted$") public void i_should_see_the_customer_details_on_the_last_row_been_deleted() throws Throwable < // Write code here to search for firstname if it does not exist WebElement dynamicDivs = driver.findElement(By.xpath(".//*[@id='bookings']")); Listrows = dynamicDivs.findElements(By.tagName("p")); java.util.Iterator i = rows.iterator(); while(i.hasNext()) < WebElement row = i.next(); System.out.println(row.getText()); if (row.getText() != "Tim") < Assert.assertFalse(row.getText(), "Tim"); >> driver.close(); driver.quit(); > 

Note that the id tag is randomly generated, which means I'll have to loop through and select the last id from the group. eg: