1

enter image description here

How do I compare the profile link count and popup count in Selenium Webdriver?

website beta-app.1bridge.in

1
  • 1
    What language are you using? You'll need to use that languages selenium commands such as find_all to load an array (for example) and then you ue the array size Commented Mar 6, 2019 at 11:33

2 Answers 2

0

For the programming language you are using:

You'll need to use that languages selenium commands such as find_all to load an array (for example) and then you ue the array size

For the popup you may need to use switch window or examine the specific div

2
  • Im using java language im not getting how to write code for that can you send one sample code to compare count matching consider recharge value in box today it showing count 10 when i click on that box one popup will come i want to add popup count and compare both Commented Mar 6, 2019 at 12:07
  • i don't know java or whatever selenium adapter it uses Commented Mar 6, 2019 at 21:09
0

Here is a sample I found at http://learnselenium.techcanvass.com/handling-a-web-table-in-selenium-3-0/ The procedure @Michael Durrant summarized above. Instead of printing, you need compare the column values of each row.

Step 1: First get the entire html table and store this in a variable ‘webtable’ of type web element.

WebElement webtable=driver.findElement(By.xpath(“html/body”));

Step 2: Get all the rows with tag name ‘tr’ and store all the elements in a list of web elements. Now all the elements with tag ‘tr’ are stored in ‘rows’ list.

//Finding & Printing number of rows

List<WebElement>rows=webtable.findElements(By.tagName(“tr”));

System.out.println(“Number of Rows including headings:”+ rows.size());

Step 3: Get the number of columns. Here we have used “tagName” of columns – “th”. Please note that this represents the heading row only.

//Finding and printing number of columns
List<WebElement>columns = rows.get(0).findElements(By.tagName(“th”));
System.out.println(“Number of columns:”+ columns.size());

Step 4: Now, we can write the code to access all the rows and columns and its values. Please note that we have used if and else to print header row and other rows.

for(int rnum=1;rnum<=rows.size();rnum++)
{
         for (int colnum=1;colnum<=columns.size();colnum++)
        {
            if (rnum==1)
             {
                  System.out.println(driver.findElement(By.xpath( “.//*[@id=’t01′]/tbody/tr[” + rnum + “]/th[”  + colnum + “]”)).getText());
            }
         else
           {
               System.out.println(driver.findElement(By.xpath( “.//*[@id=’t01′]/tbody/tr[” + rnum + “]/td[” + colnum + “]”)).getText());
          }
   }
}

Not the answer you're looking for? Browse other questions tagged or ask your own question.