Quantcast
Channel: Grafana k6 - Grafana Labs Community Forums
Viewing all articles
Browse latest Browse all 386

Page.locator() to select an element ID with a colon?

$
0
0

Hi all,

Is it possible to use Page.locator() to select an element ID that contains a colon?

I’m trying to write tests for an ancient application that uses JSF, which has tons of elements with colons in their IDs. This doesn’t work:

await page.locator("#loginForm:orgSelect").selectOption("1");

I get this error:

ERRO[0003] Uncaught (in promise) selecting option on "#loginForm:orgSelect": SyntaxError: Failed to execute 'querySelectorAll' on 'Document': '#loginForm:orgSelect' is not a valid selector.
    at CSSQueryEngine.queryAll (__xk6_browser_evaluation_script__:136:17)
    at InjectedScript._queryEngineAll (__xk6_browser_evaluation_script__:232:42)
    at InjectedScript._querySelectorRecursively (__xk6_browser_evaluation_script__:288:20)
    at InjectedScript.querySelectorAll (__xk6_browser_evaluation_script__:727:25)
    at predicate (__xk6_browser_evaluation_script__:1015:29)
    at predicate (__xk6_browser_evaluation_script__:835:14)
    at onRaf (__xk6_browser_evaluation_script__:899:27)
    at pollRaf (__xk6_browser_evaluation_script__:890:13)
    at InjectedScript.waitForPredicateFunction (__xk6_browser_evaluation_script__:843:41)
    at InjectedScript.waitForSelector (__xk6_browser_evaluation_script__:1045:17)  executor=shared-iterations scenario=browser

Fair enough. It’s not a valid selector.

Escaping the colon doesn’t work either:

await page.locator("#loginForm\\:orgSelect").selectOption("1");

It produces this error, instead:

ERRO[0003] Uncaught (in promise) selecting option on "#loginForm\\:orgSelect": getProperties: getting properties for element with ID 874584406283248700.5.4: Cannot find context with specified id (-32000)  executor=shared-iterations scenario=browser

I notice that this is not the error I would get if my selector simply didn’t match anything. I also verified that this selector does work in Chrome to apply CSS to the element.

I also tried using \3A instead of \:, with similar results.

Does anyone know if this is possible to do and, if so, what the trick is? Or does it just look like a bug? Should I open an issue on GitHub?

Many thanks in advance for any help.

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 386

Latest Images

Trending Articles



Latest Images