Skip to main content
Content improvements and formatting
Source Link
Bharat Mane
  • 6.8k
  • 11
  • 41
  • 69

How to get count of dynamic DIV's'div's' nested inside a each TD'td' tag?

I have table which have several <td> tags, again these tag have nested <div> tag. But the number of <div> are dynamic. Means, for each <td> tag number of <div> are different.

I wanted to find the total number of <div> inside a <td> and iterate them to grab each div's value.

I've tried using below xpath, but I'm not sure how can I get the count of <div>'s for loop through them.

for(int i=1;i<=NoOfDivs;i++)  
{
    WebElement NestedDivs= driver.findElement(By.xpath("/html/body/table[4]/tbody/
    tr[3]/td[2]/div["+i+"]"));
}

Webpage HTMLHTML is given in the below snap.:

enter image description here

How to get count of dynamic DIV's nested inside a each TD tag

I have table which have several <td> tags, again these tag have nested <div> tag. But the number of <div> are dynamic. Means, for each <td> tag number of <div> are different.

I wanted to find the total number of <div> inside a <td> and iterate them to grab each div's value.

I've tried using below xpath, but I'm not sure how can I get the count of <div>'s for loop through them.

for(int i=1;i<=NoOfDivs;i++) {
    WebElement NestedDivs= driver.findElement(By.xpath("/html/body/table[4]/tbody/tr[3]/td[2]/div["+i+"]"));
}

Webpage HTML is given in the below snap.

enter image description here

How to get count of dynamic 'div's' nested inside a each 'td' tag?

I have table which have several <td> tags, again these tag have nested <div> tag. But the number of <div> are dynamic. Means, for each <td> tag number of <div> are different.

I wanted to find the total number of <div> inside a <td> and iterate them to grab each div's value.

I've tried using below xpath, but I'm not sure how can I get the count of <div>'s for loop through them.

for(int i=1;i<=NoOfDivs;i++)  
{
    WebElement NestedDivs= driver.findElement(By.xpath("/html/body/table[4]/tbody/
    tr[3]/td[2]/div["+i+"]"));
}

Webpage HTML is given in the below snap:

enter image description here

how How to get count of dynamic div'sDIV's nested inside a each tdTD tag

I have table which containshave several td<td> elementstags, which again contains again these tag have nested    div<div> but the notag. But the number of div<div> are dynamic  . Means, meaning for each td<td> no.tag number of div<div> are different,.

I wanted to find the no.total number of div<div> countinside a <td> and iterate them dynamically to getgrab each div valuesdiv's value. below is what I

I've tried using below xpath, Butbut I'm not sure how can I get the count of divs before starting the<div>'s for loop through them.

for(int i=1;i<=NoOfDivs;i++) {
        WebElement NestedDivs= driver.findElement(By.xpath("/html/body/table[4]/tbody/tr[3]/td[2]/div["+i+"]"));
        }

Webpage HTML is given in the below snap.

enter image description here

how to get count of dynamic div's nested inside a each td tag

I have table which contains several td elements, which again contains nested  div but the no. of div are dynamic  , meaning for each td no. of div are different, I wanted to find the no. of div count and iterate them dynamically to get each div values. below is what I tried using xpath, But I'm not sure how can I get count of divs before starting the loop.

for(int i=1;i<=NoOfDivs;i++) {
        WebElement NestedDivs= driver.findElement(By.xpath("/html/body/table[4]/tbody/tr[3]/td[2]/div["+i+"]"));
        }

enter image description here

How to get count of dynamic DIV's nested inside a each TD tag

I have table which have several <td> tags, again these tag have nested  <div> tag. But the number of <div> are dynamic. Means, for each <td> tag number of <div> are different.

I wanted to find the total number of <div> inside a <td> and iterate them to grab each div's value.

I've tried using below xpath, but I'm not sure how can I get the count of <div>'s for loop through them.

for(int i=1;i<=NoOfDivs;i++) {
    WebElement NestedDivs= driver.findElement(By.xpath("/html/body/table[4]/tbody/tr[3]/td[2]/div["+i+"]"));
}

Webpage HTML is given in the below snap.

enter image description here

Source Link
Prasad_Joshi
  • 281
  • 3
  • 5
  • 18

how to get count of dynamic div's nested inside a each td tag

I have table which contains several td elements, which again contains nested div but the no. of div are dynamic , meaning for each td no. of div are different, I wanted to find the no. of div count and iterate them dynamically to get each div values. below is what I tried using xpath, But I'm not sure how can I get count of divs before starting the loop.

for(int i=1;i<=NoOfDivs;i++) {
        WebElement NestedDivs= driver.findElement(By.xpath("/html/body/table[4]/tbody/tr[3]/td[2]/div["+i+"]"));
        }

enter image description here