there are a few tables on the page. In one of them I need to select respective company code and then proceed. I have a problem with the following code. I don't know what approach should I use and if I get the correct company code, then how to click in it?

 public void selectCompanyCodeFromTable(String companyCode){
        int rowCount = shoppingCart.companyCodeTable.size();
        for (int i = 1; i <= rowCount; i++) {
            String sCellValue = driver.findElement(By.tagName("tr")).getText();

            if (sCellValue.equalsIgnoreCase(companyCode)) {
                System.out.println("Found the respective company code");

                //How to click/select this particular row?

  • Could you please edit your question to add the HTML code for the table? Also, please add any error message you are receiving, or describe what happens when you try to run the code in your question.
    – Kate Paulk
    Oct 12 '20 at 12:08

You already found the element that contains the company code, right? So, if that is a button, use the same findElement() method to click it:


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