Synthetic Monitoring

Hi,

I have this error on my synthetics test on Uptime Module:

page.click: Evaluation failed: DOMException: Failed to execute 'evaluate' on 'Document': The string '[href=/observability]' is not a valid XPath expression.

Configuration:

      script: |-
        step("load homepage", async () => {
            await page.goto('https://www.elastic.co');
        });
        step("hover over products menu", async () => {
            await page.hover('css=[data-nav-item=products]');
        });
        step("click observability product", async () => {
            await page.click('xpath=[href=/observability]');
        });

Any ideas of what could be the problem?

Hi Rossana. Thanks for reaching out.

You'll want to include the expected HTML element tag in your selector. Also, note that you can start XPath selectors with // as syntactic sugar.

More on XPath selectors with Playwright: Selectors | Playwright

I would try await page.click("//a[contains(@href, '/observability')]");. Let me know how it goes!

1 Like

Hi,

Thank you.

It works!!! :slight_smile:

This topic was automatically closed 24 days after the last reply. New replies are no longer allowed.