Is there any way to select a specific element from the drop-down list on the page via the splinter module in Python?
I have the following HTML code:
<select id="xyz"> <optgroup label="Group1"> <option value="1">pick1</option> <option value="2">pick2</option> </optgroup> <optgroup label="Group2"> <option value="3">pick3</option> <option value="4">pick4</option> </optgroup> </select>
Suppose I need to select the pick3 option. How can i do this?
First find the item selectusing find_by_id()and use select()to select an option:
select
find_by_id()
select()
element = browser.find_by_id('xyz').first element.select('3')
An alternative solution would be to use find_by_xpath()and click():
find_by_xpath()
click()
element = browser.find_by_xpath('//select[@id="xyz"]//option[@value="3"]').first element.click()
try
browser.find_option_by_text('pick3').first.click()
, , . select 'select (option_value)' xpath:// [@ name= "% s" ]/option [@value = "% s" ] ', . xpath , optgroups, .
element = browser.find_by_xpath ('//select [@id = "xyz" ]// [@value = "3" ]'). first element.click() , .
select_by_text() -
select_by_text()
browser.find_by_id('xyz').select_by_text("pick3")
Source: https://habr.com/ru/post/1541831/More articles:How to change thumbnail src value in Dropzone.js? - javascriptRecord video from a camera on Android in mp4 - androidAngular.js expression exception exception - angularjsFind indices where df is zero - pythonGet image from worksheet in Excel Userform - vbaCan I override console logs? - javascriptIs there a plugin to support VPAID for video.js? - javascriptVPAID & VAST standard - video.jsHow to compensate lines in matplotlib by X points - pythonregex: split in parentheses ignore nested parentheses inside quotes - javaAll Articles