无法使用量角器自动完成 select 值
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="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);
或
this.coreComponent.element(by.cssContainingText("option", value))
当 运行 带有量角器时,我们的应用程序无法识别该元素。以上两个选项都不行
根据 HTML 元素在 <select>
标签内,style
属性为 "display: none;"
因此 将无法关注该元素,因为它 不可见 。
解决方案
作为解决方案,您需要删除设置为 "display: none;"
的 style
属性,然后与元素进行交互。
PS: If possible click on the <select>
element so the options becomes visivle
参考资料
您可以在以下位置找到一些与 style="display: none;"
相关的相关讨论:
您可以在以下位置找到一些与自动完成/自动建议相关的讨论:
- How to automate Google Home Page auto suggestion?
<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);
或
this.coreComponent.element(by.cssContainingText("option", value))
当 运行 带有量角器时,我们的应用程序无法识别该元素。以上两个选项都不行
根据 HTML 元素在 <select>
标签内,style
属性为 "display: none;"
因此
解决方案
作为解决方案,您需要删除设置为 "display: none;"
的 style
属性,然后与元素进行交互。
PS: If possible click on the
<select>
element so the options becomes visivle
参考资料
您可以在以下位置找到一些与 style="display: none;"
相关的相关讨论:
您可以在以下位置找到一些与自动完成/自动建议相关的讨论:
- How to automate Google Home Page auto suggestion?