Hello,
I have a table where business contacts can be added. This table includes an autocomplete field that suggests contacts as you type. Each contact has an associated ID, but there are four different possible IDs for each contact. Because of these varying IDs, I’m having trouble assigning the correct selector for the user name input field. Could you help me with a solution to correctly assign the selector for entering the user name?
On the left side is the table where I have to enter the name. The right side shows the corresponding elements. The ID is eb7f43c44. I have tried different ways to enter the name for the correct selector but it doesn’t work. With Selenium it was really easy to just use “name=”$PpyWorkPage$pProjectDetails$pCounterParts$l2$pUserIdentifier" but with Browser libary it is not possible to use this.
Error: locator.fill: DOMException: Failed to execute ‘querySelectorAll’ on ‘Document’: ‘input[name=“$PpyWorkPage$pProjectDetails$pCounterParts$l2$pUserIdentifier”]’ is not a valid selector.
at query (:3329:41)
at :3339:7
at SelectorEvaluatorImpl._cached (:3116:20)
at SelectorEvaluatorImpl._queryCSS (:3326:17)
at SelectorEvaluatorImpl._querySimple (:3206:19)
at :3154:29
at SelectorEvaluatorImpl._cached (:3116:20)
at SelectorEvaluatorImpl.query (:3147:19)
at Object.query (:3361:44)
at :3319:21
Call log:
waiting for locator(‘input[name=“$PpyWorkPage$pProjectDetails$pCounterParts$l2$pUserIdentifier”]’).locator(‘visible=‘true’’)
When you copy paste the code, you have to replace the double quotes by real double quotes and you have to make sure there are at least 2 spaces between the arguments.
Your code may work, but it’s a little brittle because you’re selecting input element number 75. If the HTML of the page changes, then there is a big change that you select the wrong element.
I checked it again and now your first suggestion works. I don’t know what was wrong. I have reinstalled robot framework and the browser library and now it is working. Thank you @falcon030
Thanks mate for sharing these insights mate as I found it very much useful and informative to be honest also as a new member I am loving this community so far and looking forward for more such discussions.