Take the 2-minute tour ×

I've been trying for about a week to figure out a drop down menu using selenium 2. It's a project I am working on to automate a flight search using ITA Matrix 2 (http://matrix.itasoftware.com/). Everything works OK except selecting the number of passengers from the drop down menu. Clicking on it works fine, but attempts to send keys or arrow commands to both it, and the new ID which is created when it pops up, don't result in any actions. I appreciate any help! (I am very new to python, I'm doing this project as a sort of self teaching exercise to learn).

from selenium import webdriver
from time import sleep
import time

driver = webdriver.Firefox()

driver.find_element_by_id("advancedfrom1").send_keys(lport) #starting airport
driver.find_element_by_id("advancedto1").send_keys(rport) #destination airport
driver.find_element_by_id("advanced_rtDeparture").send_keys(ldate) #leaving date
driver.find_element_by_id("advanced_rtReturn").send_keys(rdate)    #return date
driver.find_element_by_id("ita_form_location_RouteLanguageTextBox_0").send_keys(lflight) #going flight number
driver.find_element_by_id("ita_form_location_RouteLanguageTextBox_1").send_keys(rflight) #return flight number

#problem code:

time.sleep(2)  #allow drop down to pop up

from selenium.webdriver.common.keys import Keys
driver.find_element_by_id("dijit_MenuItem_4_text").send_keys(Keys.DOWN)  #tried to scroll down
#also tried just sending the number directly:
share|improve this question
+1 for matrix.itasoftware.com –  Anders Nov 21 '11 at 16:43
Did you have any luck with matrix? I'm working on the same thing... –  Rizwan Kassim Jan 4 '12 at 1:37
add comment

1 Answer

up vote 2 down vote accepted

In this case, it fails because the passenger drop down menu is not actually a drop down menu, it's some clever html and javascript so it won't respond to the usual events as expected.

Try this: Click on the list at ID:


Then click the menu item at XPath (replace 'NUMBER_OF_PASSENGERS' with the number of passengers):

share|improve this answer
a little late getting back to you (just merged an old account). But I believe this helped back then and I wanted to thank you. –  cmacdona101 Jun 12 '13 at 0:13
No problem, glad I could help. –  Anders Jun 12 '13 at 14:40
add comment

Your Answer


