1

I've looked through a few solutions to select drop down elements, but none of them are working for me.

This is the html for the dropdown.

<div class="goog-inline-block goog-flat-menu-button" role="button" style="-moz-user-select: none;" tabindex="3" aria-haspopup="true">
    <div class="goog-inline-block goog-flat-menu-button-caption">Resolved</div>
    <div class="goog-inline-block goog-flat-menu-button-dropdown">&nbsp;</div>
</div>

I've tried finding the dropdown by xpath and link text with no success.

EDIT: Here's the code I'm using

import contextlib
import selenium.webdriver as webdriver
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.keys import Keys
import re
with contextlib.closing(webdriver.Firefox()) as driver:
    driver.get("https://websitename.com/#ticket/123456")
    wait = ui.WebDriverWait(driver, 30)
    wait.until(lambda driver: driver.find_element_by_xpath("//div[@class='goog-inline-block goog-flat-menu-button"))
    driver.find_element_by_xpath("//div[@class='goog-inline-block goog-flat-menu-button").click()
    driver.find_element_by_xpath("//div[@class='goog-inline-block goog-flat-menu-button").send_keys("R")
    wait6 = ui.WebDriverWait(driver, 30)

The code is supposed to change the selected drop down list element from assigned to resolved.

2 Answers 2

0

Expand the drop down menu (xpath=//div[@class='goog-inline-block goog-flat-menu-button') first then click the option to select it.

both operations can be done by click in Selenium IDE.
if click is not working then try clickAt the locators.

1
  • I tried this and it didn't recognize the xpath. I edited my original question with the code I'm trying to use.
    – JStew
    Jun 7, 2013 at 19:49
0

What xpath did you try?

The simplest I can see is:

driver.find_element_by_xpath("//div[contains(@class, 'goog-flat-menu-button-dropdown')]")

However I'm a little confused about your request about 'selecting' as this isn't a select element so I'm sorry, I'm not sure I can help there.

Try the given below method with the help of CSS Selector

driver.find_element_by_cssselector(".goog-flat-menu-button > .goog-flat-menu-button-dropdown").click();

I am sure the above CSS Selector will work.

1
  • I should have been more clear. I want to change the selected element on the dropdown.
    – JStew
    Jun 7, 2013 at 19:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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