2

i've tried different ways to solve this problem. Here's the current code:

private static List<String> getDrillOptionAfter(WebDriver driver, String from) {
        List<WebElement> menus = getDrillOptionElms(driver, from);
        List<String> drillOptions = new ArrayList<>();
        for (int i = 0; i < menus.size(); i++) {
            boolean staleElement = true;
            while(staleElement) {
                try {
                    drillOptions.add(menus.get(i).getText());
                    staleElement = false;
                } catch (StaleElementReferenceException e) {
                    drillOptions.add(menus.get(i).getText());
                    staleElement =true;
                }
            }
            }
        return drillOptions;
    }

The code tries to get the text of dropdown options. Also, in debug mode code works perfectly sometimes.

Success Shrestha
  • 433
  • 1
  • 4
  • 19

0 Answers0