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 parameter values โโ(e.g. 459, 100, etc., not text) using Selenium.
I currently 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 code, which I parse using the HTMLParser library. Is there a way to get parameter values โโusing Selenium? In other words, without having to parse the result from Selenium?
python selenium
Leonardo Cardoso
source share