Unselect single option dropdown python webdriver
<p>I am having an issue unselecting a selected option after selecting it using webdriver. I keep getting error raise NotImplementedError("You may only deselect options of a multi-select")
NotImplementedError: You may only deselect options of a multi-select</p>

<p>How can a selected pull down menu item be unselected? My code is below.</p>

<p>HTML code:</p>

<pre><code>&lt;option selected="selected" value=""&gt;&lt;/option&gt;
&lt;option value="Item 1"&gt;Item 1&lt;/option&gt;
&lt;option value="Item 2 (1)"&gt;Item 2&lt;/option&gt;
&lt;option value="Item 3"&gt;Item 3&lt;/option&gt;
</code></pre>

<p>Python Webdriver:</p>

<pre><code>options = select.find_elements_by_tag_name("option") 
for x in range(1,len(options)): 
    option = options[x]  
    options_list.append(option.get_attribute("value"))
    item_selection = Select(select)
    item_selection.select_by_visible_text("Item 1")
time.sleep()
item_selection.deselect_by_visible_text("Item 1")
</code></pre>

<p>The problem is that your dropdown select class does not have multi-select which  means that you can only select a item from the dropdown list at a time and for all deselect functions there is a check that if </p>

<pre><code>if not self.is_multiple:
            raise NotImplementedError("You may only deselect options of a multi-select")
</code></pre>

<p>and because of which its giving you error which is expected since deselect should only work with multi-select dropdowns.</p>

<p>The work around is use select_by_index() or select_by_value() or select_by_visible_text() of another element to change the selection from the selected one to another.</p>

<p>And if you are practising deselect then try it on page which supports multi-select </p>

python selenium