I need to run thousands of searches on a certain database and I'm using Python and Selenium WebDriver to automate it. The thing is, the frame that contains the search results has a name that is dynamically generated. That name always begins the same way (say, "results_frame") and then it's followed by a bunch of numbers that change every time (like "results_frame1298120910290"). So, based on a few hours of googling, I tried using xpath:
framename = driver.find_elements_by_xpath("//frame[contains(@name, 'results_frame')]")
driver.switch_to_frame(framename)
No good. When I print 'framename', what I get is this:
[<selenium.webdriver.remote.webelement.WebElement object at 0x101206350>, <selenium.webdriver.remote.webelement.WebElement object at 0x101206390>]
Instead of the actual name of the frame.
I've also tried using indexes (as in driver.switch_to_frame(0), driver.switch_to_frame(1), etc), as suggested here, but no good either.
So, how can I retrieve a frame's name when that name is dynamically generated? Any thoughts?
(Python 2.7.5, Selenium 2.2.0, Mac OS X 10.6.8, Firefox 22.0)