Problem with counting child divs of one level out of parent div in Selenium Java

43 Views Asked by At

It is my first post here so please advise if I'm not too specific.

Problem: On "https://justjoin.it/all-locations/testing/with-salary_yes" site I am trying to get number (count) of div child div elements from a parent div. Parent is a list of advertisiments leveled one under another.

Solution I use:

WebElement adsList = driver.findElement(By.xpath("/html/body/div[1]/div[2]/div/div/div[2]/div/div/div[3]/div/div[2]"));
List<WebElement> ads = adsList.findElements(By.xpath("//*[@id="__next"]/div[2]/div/div/div[2]/div/div/div[3]/div/div[2]"));
    int adsCount = ads.size();

For this solution particular solution I either get value 0 in return or error finding selector.

0

There are 0 best solutions below