Hi I'm learning automation testing using Eclipse, Selenium Webdriver, and Java. I'm practicing. I'm trying to select the label 'Consumer Electronics' from the Ebay dropdown menu and search only in that category. Below script is what I have. It runs but what I notice is even though it will open the drop down and highlight 'Consumer Electronics', it actually is still searching in 'All Categories'. I'm using css to select 'Consumer Electronics'. What am I doing wrong?


import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver;
public class EbayTest {

public static void main(String[] args) {
    WebDriver driver = new FirefoxDriver();
    driver.findElement(By.name("_nkw")).sendKeys("Klipsch Status");



  • Hi @JohnP15, welcome to SQA. Thanks for including your code snippet in your answer, that's always a good move for this kind of question. I think your question is answered by the link Yamikuronue has given, so I'm going to put this on hold for now - but if you go over to that question, and find that actually it doesn't quite fit, please re-edit your question with specific details of how it doesn't answer it, and what you need, and we can reopen it. We're trying to avoid duplicating Selenium questions where we can, because otherwise it makes it tough to find the answer you need.
    – testerab
    May 17 '15 at 18:54

I am not able to access Ebay in my pc because of some firewall restriction , but I can help you by example :

You will need to use Select object to select value from dropdown.

For ex :


Select sel = new Select(driver.findElement(By.id("continents")));

So you need to pass your actual dropdown id and text of dropdown value which you want to select.


I won't add the same as what's already been said, but.. I noticed one of your selectors is by option value 293, or similar As a rule of thumb, try not to use numerical or 'generated' selectors on things like this, as if there were another option added to the drop down you might end up selecting a totally different option.

  • Hi, the option value=293 is what i got for the css of 'Consumer Electronics' from the ebay homepage drop down. Thats why i used it. Is using label in option? or does that only work w RC?
    – JohnP15
    Apr 18 '15 at 0:38
  • @JohnP15 yeah personally I'd select the drop down option by the containing text, like suggested in helping hands' answer. You can use the select class for this, it's specifically for working with drop down menus :)
    – chrisc
    Apr 18 '15 at 10:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.