running into an additional problem The code is not finding the string that equals 8QQ which is a match here is my full code.
String selector = "div#companyIdBarCompListGrid_rows_scrollpane table tbody tr[id*=companyIdBarCompListGrid_] td span div a"; int links = driver.findElements(By.cssSelector(selector)).size(); System.out.println("Number of links: " + links); // begin inner for-loop for (int i = 0; i < links; i++) { PP_OBJ_CycleData.ScrollToTop(driver);// scroll up List<WebElement> CCTable = driver.findElements(By.cssSelector(selector)); WebElement code = CCTable.get(i); System.out.println("\n"+code.getText().substring(0, 3).trim()+"\n"); //code.click(); //----------------------checking for bad code ----------------------------------------- String[] badcodes = {"8QQ", "8BQ", "8JQ"}; boolean check = Arrays.asList(badcodes).contains(code); System.out.println(check); //check == true will work as well if(check){ System.out.println(check+"Bad Code found breaking loop"); break; }else{ //checking to make sure element is clickable PP_OBJ_CycleData.isClickable(code, driver); System.out.println("Clickable?"+ code.isEnabled()); code.click(); }
I think the problem is this part here:
List<WebElement> CCTable = driver.findElements(By.cssSelector(selector)); WebElement code = CCTable.get(i); System.out.println("\n"+code.getText().substring(0, 3).trim()+"\n"); //code.click();
I am cutting off everything but the first 3 characters with sub string but that is during the print statement. however the string is actually longer or has more characters than what is in the array for 8QQ. Could this be the problem if so is there a way to get around it?