Please help me in selecting a random country name from country name dropdown each time running the script.
I want to try using xml.
XPATH of dropdown is .//*[@id='intselect']
HTML code:
<select id="intselect" name="intselect" onchange="setCurrency(this);">
<option value="US">UNITED STATES</option>
<option value="AG">ANTIGUA AND BARBUDA</option>
<option value="AR">ARGENTINA</option>
<option value="AW">ARUBA</option>
<option value="AU">AUSTRALIA</option>
<option value="AT">AUSTRIA</option>
<option value="BH">BAHRAIN</option>
<option value="BD">BANGLADESH</option>
</select>
countryname.xml
<?xml version="1.0" encoding="UTF-8"?>
<array name="testArray">
<country>
<countryname>UNITED STATES</countryname>
</country>
<country>
<countryname>ANTIGUA AND BARBUDA</countryname>
</country>
<country>
<countryname>ARGENTINA</countryname>
</country>
<country>
<countryname>ARUBA</countryname>
</country>
<country>
<countryname>AUSTRALIA</countryname>
</country>
</array>
//Method to fetch random value from XML
public void Fetch_XML()
      {
             SAXBuilder builder = new SAXBuilder();
             File xmlFile = new File("C:\\Documents and Settings\\vlakshm\\MyTNG\\list\\countrynames.xml");
             Element node = null;
             try {
              //Element result=null;
            Document document = (Document) builder.build(xmlFile);
            Element rootNode = document.getRootElement();
            List list = rootNode.getChildren("country");
            Random random = new Random();
            int newcountryname= random.nextInt(list.size());
            node = (Element) list.get(newcountryname);
             }//End of Try loop
             catch (IOException io) {
            System.out.println(io.getMessage());
             } catch (JDOMException jdomex) {
            System.out.println(jdomex.getMessage());
             }
             node.getChildText("countryname");
             //element_array = driver.findElement(By.xpath("//select[@id='intselect']/option"));
         }//End of randomPartnum method
// I m calling that method to chose in drop down
public void Choser() {
      Fetch_XML();
      driver.findElement(By.id("intselect")).click();      
        System.out.println("---------------------------------------");
        System.out.println("Country choser layer test case-Success");
        System.out.println("---------------------------------------");
  } 
but m getting null pointer exception.Can anybody help me to sort out the problem in code
 
     
     
    