Unable to select value from autocomplete using protractor

百般思念 提交于 2021-01-28 18:31:10

问题


<select name="Name" class="metaselect ignore" style="display: none;" xpath="1">   <option value="00000000-0000-0000-0000-000000000000" selected="selected">-- New --</option>    <option value="bd434f35-90db-e911-aa59-a96c125b4266">AddtoTest</option>    <option value="e8b6fd1b-e2f3-e911-aa64-e16c52c442dc">APINV_EPIC06</option>    <option value="35cfdd50-c47a-e911-aa37-8fe9ba6f0d87">Approve</option>    <option value="70da50aa-e2a3-e911-aa45-8f65b76e1edb">Basic</option>    <option value="5af85ad8-5ac0-e911-aa4f-b51108e06dbe">cont</option>    <option value="1c9b4449-90db-e911-aa59-a96c125b4266">Contentgenrat</option>    <option value="7ea80473-ecdd-e911-aa5b-cc08702b7e65">CTB1</option>    <option value="fb0b16cb-5fc9-4938-8cdb-b28b0ac3a065">Default</option>    <option value="5b904ca0-8adb-e911-aa59-a96c125b4266">delete</option>    <option value="9cd4dc48-910b-ea11-aa6c-879f4a104148">GP - US Expense Report</option>    <option value="7a87e6ae-75b3-e911-aa4b-a33f065bbcc1">INVOICE</option>    <option value="2860a55d-90db-e911-aa59-a96c125b4266">norconnoradd</option>    <option value="df57386a-90db-e911-aa59-a96c125b4266">olaa</option>    <option value="f299ad9c-91db-e911-aa59-a96c125b4266">qwerty</option>    <option value="2fa1a597-63d9-e911-aa59-a96c125b4266">Test1</option>    <option value="14d4d010-5bc0-e911-aa4f-b51108e06dbe">ton</option>    <option value="4e0506f8-bd7a-e911-aa37-8fe9ba6f0d87">View</option>    <option value="15086a03-ebc8-e911-aa54-ce643b10106b">WithNavFieldGroup</option>   </select>
<input "="" class="ui-state-default isCombo [object Object] ui-autocomplete-input ui-widget ui-widget-content ui-corner-left metaselect" autocomplete="off" name="Name" data-uicombobox="[object Object]" xpath="1">
<a tabindex="-1" class="ui-button ui-widget ui-button-icon-only ui-corner-right ui-button-icon" role="button" xpath="1"><span class="ui-button-icon ui-icon ui-icon-triangle-1-s"></span><span class="ui-button-icon-space"> </span></a>
await element(by.xpath("//span[@class='ui-combobox']//input[@name='Name']")).sendKeys("cont);

or

this.coreComponent.element(by.cssContainingText("option", value))

Our application when run with protractor doesn't recognize the element. Both the above options doesn't work


回答1:


As per the HTML the element is within a <select> tag with style attribute as "display: none;"

So Selenium won't be able to focus on the element as it is not visible.


Solution

As a solution you need to remove the style attribute which is set as "display: none;" and then interact with the element.

PS: If possible click on the <select> element so the options becomes visivle


References

You can find a couple of relevant discussions related to style="display: none;" in:

  • Expected condition failed: waiting for element to be clickable for element containing style=“display: none;”
  • How can i upload files on dropzone.js with style=“display: none;” using Selenium?
  • Element changes from display: none to display:block selenium python

You can find a couple of relevant discussions related to Auto Complete / Auto Suggestions in:

  • Selecting options from Auto Complete Dropdown using selenium web driver in python
  • How to search, arrow down and press enter with Selenium
  • How to automate Google Home Page auto suggestion?


来源:https://stackoverflow.com/questions/59207242/unable-to-select-value-from-autocomplete-using-protractor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!