Handling Rabdom Date Picker Wheel on IOS Native App


Can you please help me in selecting random value from dropdown in custom applications.

My code:

Method type - 1
public void testingMethod(){

	 String sampleString = driver.findElements(By.xpath("//UIAApplication[1]/UIAWindow[4]/UIAPicker[1]")).get(0).getAttribute("values"); 
	 String[] items = sampleString.split(","); 
	 List<String>itemList = new ArrayList<String>(); 
	 for (String item : items) {
	 Random rad = new Random(); 
	 String stri =itemList.get(rad.nextInt(itemList.size())); System.out.println(itemList);

Method type - 2
public void testMet(){

	 WebElement drpDwnList = driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[4]/UIAPicker[1]")); 
	 //Using FindElements to create a List object //
	 List <WebElement> weblist =driver.findElements(By.xpath("//UIAApplication[1]/UIAWindow[4]/UIAPicker[1]")); 
	 //Using Select Class to fetch the count 
	 Select objSel = new Select(drpDwnList); 
	 List <WebElement> weblist = objSel.getOptions(); 
	 //Taking the count of items
	 int iCnt = weblist.size(); 
	 //Using Random class to generate random values
	 Random num = new Random(); 
	 int iSelect = num.nextInt(iCnt); 
	 //Selecting value from DropDownList objSel.selectByIndex(iSelect); //Selected Value

Method type - 3

Please help me in resolving this issue

Thanks in advance.