I'm trying to automate some admin tasks at work, so I'm using selenium to manipulate our project management platform (quickbase).
The first item I populate is a select/options drop down, which I can select a record by using the xpath selector:
driver.find_element_by_xpath("//select[@id='_fid_67']/option[@value='28']").click()
This works just fine. The next item I need to populate is also a select/options drop down. The available options are queried by the first selected option. In firebug it looks like they are calling the function to query the results on click of the 2nd drop down. So next I tried just clicking the select element id, which should call the function to query the options. Then I let it wait (tried for as long as 10 seconds), and select the option.
# click the select element to call function
driver.find_element_by_xpath("//select[@id='_fid_74']").click()
# wait for the query function to finish
driver.implicitly_wait(2)
# select the option
driver.find_element_by_xpath("//select[@id='_fid_74']/option[@value='142']").click()
This gives me one of two errors:
Element not found in the cache - perhaps the page has changed since it was looked up
or
File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 107, in check_response
message = value["value"]["message"]
TypeError: string indices must be integers
I also tried returning a list of elements, looping through them and checking if the value '142' and if so click that element object. That gave me an error as well. I've tried using xpath:
//select[@id='_fid_74']/option[text()='the text']
which didn't work either.
I assume it has something to do with the conditional selection, since the same query worked for the first dropdown (first code block).
Anyone have any suggestions?