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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -