csspuppeteerui-automationpuppeteer-sharpjest-puppeteer

Puppeteer - Unable to select an input box based on -p-aria and -p-text


I am automating an web application and I need to type in a value in an input text box.

My plan is to develop an friendly function, where in if I pass the label associated with the text , I should be able to enter the value. In this scenario, I am not dependant on xpaths or anything else, only the label. I figured out the selector. It is

selector = `::-p-aria(${textboxLabel}) ::-p-aria([role="textbox"])`;

but the issue is the text box label. We dont know the exact label text but only a partial label text. What I mean by here is , it can be like any of the below

enter image description here

Is it possible to get a selector which satisfies a partial label text, in this case, "First"

Its an augular application and WCAG2.0 compatible. But -p-aria only supports exact label text

Tried,

 selector = `::-p-text(${textboxLabel})`;
but it is pointing to the label element and not to the input element.

Any help is appreciated. I am after a selector which gets the partial text as input and any other input ( which is generic ) to identify the text box, I mean point to the input tag. Thank you


Solution

  • Thanks everyone for responding to my question. Unfortunately, Puppeteer does not have a direct answer to this scenario. The only way to achieve the outcome is to filter out all text boxes and then apply another filter to find the right text box. Not an direct fix but an hack based on the label element.

    I mean, formulate an XPath to find an label element which has "First" and then from that collection, apply an index.

    Happy to help if you need more information

    STEP 1 : Find all text boxes. =>collection1[]

    STEP 2 : Find those text boxes who has First as an associated Label=>collection2[]

    STEP 3 : Fetch as per the index, Say collection2[0]