I am trying to select one of the dropdown list value using select class Getting the err ElementNotInteractableException element not interactable

+1 vote

Here is the HTML code:

<input class="select-dropdown dropdown-trigger" type="text" readonly="true" data-target="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b4" style="" xpath="1">
<ul id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b4" class="dropdown-content select-dropdown" tabindex="0" style="" xpath="1"><li class="disabled" id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b40" tabindex="0"><span>Choose</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b41" tabindex="0"><span>Marriage</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b42" tabindex="0" class="selected"><span>Home Renovation</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b43" tabindex="0"><span>Holiday Planning</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b44" tabindex="0"><span>Debt Refinancing</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b45" tabindex="0"><span>Medical Emergency</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b46" tabindex="0"><span>Others</span></li></ul>
<svg class="caret" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" xpath="1"><path d="M7 10l5 5 5-5z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg>
<select class="" type="select" id="7" options="[object Object]" name="loan_purpose" tabindex="-1" xpath="1"><option value="" disabled="" selected="">Choose</option><option value="1">Marriage</option><option value="2">Home Renovation</option><option value="3">Holiday Planning</option><option value="4">Debt Refinancing</option><option value="5">Medical Emergency</option><option value="6">Others</option></select>

I could able to click on the dropdown list using the below code:

WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='select-dropdown dropdown-trigger']"))).click()

self.driver.find_element_by_xpath("//select[@name='loan_purpose']/option[text()='Home Renovation']").click()

when I am trying to select the value using this code,getting the error message:

unable to select the value in the dropdown list,getting the following error message:
ElementNotInteractableException: Message: element not interactable: Element is not currently visible and may not be manipulated (Session info: chrome=77.0.3865.90)

Oct 17, 2019 in Selenium by anonymous
• 160 points
6,174 views

1 answer to this question.

+1 vote
Best answer

Hi there, you are facing this error because in your code you are using class name with xpath to select the item, but class name is not providing a single class name. "select-dropdown dropdown-trigger" is not a single class, but two classes used to provide properties to your Select element. So its better to use other locator like id or name or use ChroPath to get xpath for your required element.

answered Oct 17, 2019 by Abha
• 28,000 points

selected Oct 21, 2019 by Swarna

Thank you for looking in to the question.  I am new to automation.

i tried with this code

self.driver.find_element_by_xpath("//span[contains(text(),'Home Renovation')]").click()

it was selecting the value.



So are you facing any other problem? Or it worked for you?

Hi there,I still encounter the problem with this code

self.driver.find_element_by_xpath("//span[contains(text(),'Home Renovation')]").click()

It is selecting the value "marriage" instead of Home Renovation.

why it is selecting that value?

i do change the code with self.driver.find_element_by_xpath("//span[contains(text(),'Others')]").click() but then it is 

selecting the value "Debt Refinancing".

Please help out.

Hi there,I still encounter the problem with this code

self.driver.find_element_by_xpath("//span[contains(text(),'Home Renovation')]").click()

It is selecting the value "marriage" instead of Home Renovation.

why it is selecting that value?

i do change the code with self.driver.find_element_by_xpath("//span[contains(text(),'Others')]").click() but then it is 

selecting the value "Debt Refinancing".

Please help out.

Hi Swana, while providing the xpath("//span[contains(text),'Others']") instead of using contains method in xpath, try using index number used to write dropdown items. Every dropdown item must have an index number. Use that to get the element.

Hi Abha,

In my HTML code, i didn't see any index attribute for the span tag.Please go through the HTML code.

<input class="select-dropdown dropdown-trigger" type="text" readonly="true" data-target="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b4" style="" xpath="1">
<ul id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b4" class="dropdown-content select-dropdown" tabindex="0" style="" xpath="1"><li class="disabled" id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b40" tabindex="0"><span>Choose</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b41" tabindex="0"><span>Marriage</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b42" tabindex="0" class="selected"><span>Home Renovation</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b43" tabindex="0"><span>Holiday Planning</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b44" tabindex="0"><span>Debt Refinancing</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b45" tabindex="0"><span>Medical Emergency</span></li><li id="select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b46" tabindex="0"><span>Others</span></li></ul>
<svg class="caret" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" xpath="1"><path d="M7 10l5 5 5-5z"></path><path d="M0 0h24v24H0z" fill="none"></path></svg>
<select class="" type="select" id="7" options="[object Object]" name="loan_purpose" tabindex="-1" xpath="1"><option value="" disabled="" selected="">Choose</option><option value="1">Marriage</option><option value="2">Home Renovation</option><option value="3">Holiday Planning</option><option value="4">Debt Refinancing</option><option value="5">Medical Emergency</option><option value="6">Others</option></select>

Hi Swarna, so in case you aren't able to see index attribute, then in that case you can try this code snippet to first get all the list options:

resultSet = driver.find_element_by_xpath("//section[@id='abc']/ul")
options = resultSet.find_elements_by_tag_name("li")

To loop through list of <li> nodes simply do:

for option in options:
    print(option.text)

which locator i should use in this case 

//section[@id='abc']/ul
if i understand correctly,i should provide the locator id of Ul tag
which is this 
"select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b4" .plz confirm.

Yes, the Id would be this only, but are you using section tag before ul tag?  Because 

//section[@id='abc']/ul

means section is the parent tag/node of ul

When i executed this  below code

resultSet = driver.find_element_by_xpath("//section[@id='select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b4']/ul")
options = resultSet.find_elements_by_tag_name("li")
for option in options:
    print(option.text)

I am getting the following error message:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//section[@id='select-options-6a055dc1-379b-0ad4-c88a-bfd07a8356b4']/ul"} (Session info: chrome=77.0.3865.90)

Related Questions In Selenium

+1 vote
2 answers

Is it possible to manually set the attribute value of a Web Element using Selenium?

WebDriver driver; JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("document.getElementById('id123').setAttribute('attr', ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,010 points
17,375 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
4,361 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,010 points
5,282 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
3,160 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2, 2020 in Selenium by Sri
• 3,010 points
3,681 views
0 votes
1 answer
0 votes
2 answers

I am trying to run the below code but java.lang.Illegalstate Exception is coming

You are facing this error because while ...READ MORE

answered Jun 21, 2019 in Selenium by Abha
• 28,000 points
293 views