Comment obtenir l'option sélectionnée avec Selenium WebDriver avec Python?

Comment obtenir de l'option sélectionnée à l'aide de Selenium WebDriver avec Python:

Quelqu'un a une solution pour un getFirstSelectedOption?

Je suis en utilisant cela pour obtenir de l'élément select:

try:
    FCSelect = driver.find_element_by_id('FCenter')
    self.TestEventLog = self.TestEventLog + "<br>Verify Form Elements: F Center Select found"
except NoSuchElementException:
    self.TestEventLog = self.TestEventLog + "<br>Error: Select FCenter element not found"

Est-il une ou l'équivalent, ou quelque chose de proche de "getFirstSelectedOption" comme ceci:

try:
    FCenterSelectedOption = FCenterSelect.getFirstSelectedOption()
    self.TestEventLog = self.TestEventLog + "<br>Verify Form Elements: F Center Selected (First) found"
except NoSuchElementException:
    self.TestEventLog = self.TestEventLog + "<br>Error: Selected Option element not found"

Alors je voudrais Vérifier le Contenu avec un getText comme:

try:
    FCenterSelectedOptionText = FCenterSelectedOption.getText()
    self.TestEventLog = self.TestEventLog + "<br>Verify Form Elements: FCenter Selected Option Text found"
except NoSuchElementException:
    self.TestEventLog = self.TestEventLog + "<br>Error: Selected Option Text element not found"

if FCenterSelectedOptionText == 'F Center Option Text Here':
    self.TestEventLog = self.TestEventLog + "<br>Verify Form Elements: F Center Selected Option Text found"
else:
    self.TestEventLog = self.TestEventLog + "<br>Error: F Center 'Selected' Option Text not found"

source d'informationauteur Matthew Cox