无法使用量角器从自动完成功能中选择值 [英] Unable to select value from autocomplete using protractor
问题描述
< select name ="Name" class ="metaselect ignore" style ="display:none;"xpath ="1">< option value ="00000000-0000-0000-0000-000000000000" selected =已选择">-新建-</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">批准</option>< option value ="70da50aa-e2a3-e911-aa45-8f65b76e1edb">基本</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">默认</option>< option value ="5b904ca0-8adb-e911-aa59-a96c125b4266">删除</option>< option value ="9cd4dc48-910b-ea11-aa6c-879f4a104148"> GP-美国支出报告</option>< option value ="7a87e6ae-75b3-e911-aa4b-a33f065bbcc1">发票</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">查看</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 ="[对象对象]" 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元素(by.xpath("//span [@ class ='ui-combobox']//input [@ name ='Name']")).sendKeys("cont);
或
this.coreComponent.element(by.cssContainingText("option",value))
与量角器一起运行时,我们的应用程序无法识别该元素.以上两个选项均无效
按照HTML,该元素位于< select>
标记内,且 style
属性为 显示:无;"
因此硒将无法运行重点关注元素,因为它不可见.
解决方案
作为解决方案,您需要删除设置为 "display:none;"
的 style
属性,然后与该元素进行交互
PS :如果可能,请单击
< select>
元素,以使选项可见
参考文献
您可以在以下位置找到与 style ="display:none;"
相关的一些相关讨论.
您可以在以下位置找到与自动完成/自动建议相关的一些相关讨论.
<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
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?
这篇关于无法使用量角器从自动完成功能中选择值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!