Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
254 views
by Contributing Tester (51 points)
edited by
I have a drop down (country) which has 250 countries listed inside it    and i am able to print the text of all country so I want to verify the all country one by one using assert with the respective requirement.  In assert, i will verify one by one with test data.

Test Scenario, No extra country getting added in the drop down and no country missing from the drop down.

What is the solution for it?

2 Answers

0 like 0 dislike
by Contributing Tester (99 points)

This is what I did in my last applicaiton in the similar scenario.

1. Get all values from Test Data and covert it all into Comma Seperated Value String.

e.g. County1, County2, Country3 ... save it as TDString

2. Get all values from the dropdown and covert it all into Comma Seperated Value String.

e.g. Country1, Country2, country3 .. save it as ActualString

Now compare two string,

TDString.equal(ActualString);

This way, you will be able to compare that all data are equal in TestData. Number of countries match. Also, it will make sure that case matches.

 

Also, you can use ArrayList to compare.

import java.util.ArrayList;

public class ComparingList {
   public static void main(String[] args) {
      ArrayList<String> list1 = new ArrayList<String>();
      list1.add("Country"); //Add all countries from TestData
      ArrayList<String> list2 = new ArrayList<String>();
      list2.add("Country"); //Add all countries from DropDown
      assertEquals(list1, list2);
   }
}


Hope that helps.

by Contributing Tester (51 points)
I will try and get back to you.
Thanks
0 like 0 dislike
by
Hi,

Get the list of options in the drop down using the driver.findelements method and save it in a list of webelement. Now iterate each item in the list and extract the value using .getText method and assert.
by Contributing Tester (51 points)
I will try and get back to you.
Thanks


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...