0
    @Test
    public void MedicineList() throws InterruptedException {
        driver.get(sitedata.getProperty("Medication_url"));

        WebElement mainmenu = isElementPresentt("dog_xpath");
        Thread.sleep(2000);

        Thread.sleep(1000);
        WebElement mains = isElementPresentt("dog_list_div_xpath");
        List<WebElement> sub = mains.findElements(By.tagName("a"));

        for (int i = 0; i < sub.size(); i++) {
            System.out.println(sub.get(i).getText());

            WebElement subMenu = isElementPresentt("Allergy_xpath");
            Thread.sleep(2000);
            Actions a = new Actions(driver);
            a.moveToElement(mainmenu).build().perform();            
            WebElement main2 = isElementPresentt("dog_alg_sub_div_xpath");
            List<WebElement> sub2 = main2.findElements(By.tagName("a"));
            for(int j=0; j<sub2.size();j++) {
                a.moveToElement(subMenu).build().perform();
                Thread.sleep(500);
                System.out.println("SUB MENU:"+sub2.get(j).getText());
            }

        }

    }
  • 1
    What is the difference of your code result against your expectations? Why do you need that List? The elements might go stale when not hovered so become useless. – Alexey R. Nov 19 at 12:52
  • Bcause i want to click on that one by one and get some details from that page. – Krina Modi Nov 20 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.