I have the following HTML code
<select name="countries" class_id="countries">
<option value="-1">--SELECT COUNTRY--</option>
<option value="459">New Zealand</option>
<option value="100">USA</option>
<option value="300">UK</option>
</select>
I am trying to get a list of the option values (like 459, 100, etc, not the text) using Selenium.
At the moment I have the following Python code
from selenium import webdriver
def country_values(website_url):
browser = webdriver.Firefox()
browser.get(website_url)
html_code=browser.find_elements_by_xpath("//select[@name='countries']")[0].get_attribute("innerHTML")
return html_code
As you can see the code returns pure HTML, which I am parsing with HTMLParser library. Is there any way to get the option values just using Selenium? In other words, without having to parse the result from Selenium?