Technical Project Lead @ Huawei Technologies

My photo
Bangalore/Hyderabad, Karnataka/Andhra Pradesh, India
Have an overall 10 + yrs of experience Currently working as an Senior Architect.Expertise in design,implementation of Automation frameworks for Opensource automation tools like Selenium,Jmeter, Webdriver,Appium, Robotium Expertise in integrating Test & ALM Management tools like Rally,Qmetry,JIRA-Zephyr with Automation frameworks Expertise in design and developmenet Mobile Automation frameworks for tools like Appium, Robotium Remote Control,Cucumber BDD


Wednesday, September 1, 2010

How to print all the available options in a dropdown

    static SeleniumServer server;
    static Selenium selenium;
    public void testPrintDropdownValues() throws InterruptedException
        //Start the server
        try {
        } catch (Exception e) {
            // TODO Auto-generated catch block
            System.out.println("Failed to start the server");
        //Stop the server
        //Start the selenium session
        selenium = new DefaultSelenium
        //click on Advanced Search Window"link=Advanced Search");    
        //Print all the available options from the results dropdown in the google advanced search page
        String[] options = selenium.getSelectOptions("name=num");       
        //The above command returns a array of strings(options)
        for (int i = 0; i < options.length; i++) {
            System.out.println("Option: " + i + " is" + options[i]);
        //Stop & close the selenium browsers

No comments:

Post a Comment