Getting error in printing values from dropdownlist

39 views
Skip to first unread message

VARISA SHAH

unread,
Apr 22, 2015, 3:56:52 AM4/22/15
to seleniu...@googlegroups.com
Hi all,

I wrote the following program in printing the values from the dropdownlist:

package testproject;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class Xyz {

    public static void main(String[] args) {
   
        WebDriver driver = new FirefoxDriver();
        String BaseUrl = "http://newtours.demoaut.com/";
        driver.get(BaseUrl);
        driver.findElement(By.linkText("Register here")).click();
        driver.get("http://newtours.demoaut.com/mercuryregister.php");
        Select drpCountry = new Select(driver.findElement(By.name("country")));
       
        drpCountry.selectByVisibleText("ANTARTICA");
         driver.close();
         System.exit(0);
    }

}

I am getting the following error , when i run this program:

at org.openqa.selenium.support.ui.Select.selectByVisibleText(Select.java:149)
    at testproject.Xyz.main(Xyz.java:18)

Can anyone please help me with this.

Thanks,
Varisa

tulsi.tester

unread,
Apr 22, 2015, 5:23:44 AM4/22/15
to seleniu...@googlegroups.com
HI Varisha,

There is no visible text ANTARTICA, instead there is a visible text ANTARCTICA

Pramod Jain

unread,
Apr 22, 2015, 10:01:17 AM4/22/15
to seleniu...@googlegroups.com
Hi Varisa,

Please try this

drpCountry.selectByVisibleText("ANTARCTICA");

I think it is typo.Please check let me know.

Thanks,
Pramod

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0d44a78f-8046-4566-8a45-078b94bcb459%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages