Monday, July 29, 2019

Question: How do you check whether a table data(values) is sorted or not? Sorting happens when clicking on Table Header(Ex: Name, which is a link).
Name
Venu
Avinash
Dharma
Answer:
We can take an array of String type as expected values and consider the column values which need to be verify are as actual values. Which can be resolved by below example.


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CompareTwoLists {
       public static void main(String[] ar){
              List<String> expdValues = new ArrayList<String>();
              expdValues.add("venu");
              expdValues.add("avinash");
              expdValues.add("dharma");
              Collections.sort(expdValues);     //to arrange given list in sorting
             
              List<String> actValues = new ArrayList<String>();
              actValues.add("dharma");
              actValues.add("venu");
              expdValues.add("avinash");
              Collections.sort(actValues);
             
              if(expdValues.equals(actValues)){
                     System.out.println("Given Lists are Matched");
              }else{
                     System.out.println("Given lists are not matched");
              }
       }
}



0 comments:

Post a Comment

selenium-repo by venu

Blog helps to a student or IT employee to develop or improve skills in Software Testing.
For Online Classes Email us: gadiparthi122@mail.com

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts