python - Get values of multiple select with Selenium? -
i have multiple select element:
<select multiple="multiple" id="myselect"> <option value="al">alabama</option> <option value="ak">alaska</option> ... </select>
how can values of element selenium?
this have:
elem = self.browser.find_element_by_css_selector('#myselect') self.assertequal('ny', denom_val.get_attribute("value")[0]) self.assertequal('co', denom_val.get_attribute("value")[1])
but in fact, get_attribute
returning string, not array of values. guess because selenium doesn't spot it's multiple element.
is there way around this?
this java way asking. hope help. cheers.
// values array list<webelement> selelement = driver.findelements(by.cssselector("select#myselect > option")); string[] seltext = new string[selelement.size()]; // text of corresponding elements array int index = 0; for(webelement element : selelement){ seltext[index++] = element.gettext(); } assert.assertequals("alabama" ,seltext[0]);
Comments
Post a Comment