still new to selenium, xpath works great most of time , but not with the drop down in this case, of selecting a element from a drop down box:
the xpath of the box is:
//*[@id="select2-report_object-container"]
I get the browser to click it, now it shows a dropdown of options, now I want to select the element "title" APP 7.08 from the list.
xpath wont work , as it just shows the container
//*[@id="select2-report_object-container"]
element to be selected is as follows:
<span class="select2-selection__rendered" id="select2-report_object-container" title="APP 7.08">APP 7.08</span>
tag name wont work, link name either , also tried with id and then the title value
Message:
no such element: Unable to locate element
I also tried
selenium.select('//*[@id="select2-report_object-container"]' , title="APP 7.08";
no luck .
I feel like I need to add a second argument to the initial xpath or ID but not sure what to use to call the value of APP 7.08 from the span.
<span class="select2-selection__rendered" id="select2-report_object-container" title="APP 7.08">APP 7.08</span>
can anyone help ?
I assume you know which option you are going to select, so you can use visible text or value to get it done.
select = Select(driver.find_element_by_id('select2-report_object-container'))
# select by visible text
select.select_by_visible_text('title')
# select by value
select.select_by_value('title')
You can try below code :-
select= select(driver.find_element_by_name('location'))
select.select_by_value(17) or
select.select_by_visible_text('APP 7.08')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.