question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to pass "Predicate" argument to ``wait for`` keywords

See original GitHub issue

Describe the bug I cannot pass in input of Wait For Response a predicate matcher, it is always considered as a url. Documentation states

matcher Request URL string, JavaScript regex or JavaScript function to match request by. By default (with empty string) matches first available request.

But there are no example on how to pass a predicate

To Reproduce Steps to reproduce the behavior:

Wait For Response  matcher=request => request.url() === 'https://example.com' && request.method() === 'GET'

Expected behavior Wait for the request with given url and method

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chromium
  • Version: robotframework-browser==9.0.2

Additional context Note that my need behind is to be able to wait for a specific request method (sometimes I am polluted with the OPTIONS requests, so I want to filter them out)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rsandbachcommented, Nov 24, 2021

This should be resolved with #1533. I wasn’t sure how to associate it with this issue.

1reaction
jpobleycommented, Nov 15, 2021

Desktop (please complete the following information): OS: MacOS 11.6 Browser: Chromium Version: robotframework-browser==10.0.3

I also ran into this issue. Curiously, waitForRequest and waitForResponse do different things; I’m not sure if it’s related:

waitForResponse

export async function waitForResponse(request: pb.Request.HttpCapture, page: Page): Promise<pb.Response.Json> {
    const urlOrPredicate = new RegExp(`.*${request.getUrlorpredicate()}`);
    ...
    ...
}

waitForRequst

export async function waitForRequest(request: pb.Request.HttpCapture, page: Page): Promise<pb.Response.String> {
    const urlOrPredicate = request.getUrlorpredicate();
    ...
    ...
}

EDIT I removed the part of my comment regarding POST methods–it occurred to me after reading @Leemur89 's comment more carefully that I wasn’t filtering out OPTIONS requests, which would explain the protocol error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++11 - Trying to use lambda functions as predicate for ...
The wait method for the condition_variable class has a predicate as second argument, so I thought of using a lambda function:
Read more >
karate/README.md at master - GitHub
A very powerful variation of waitUntil() takes a full-fledged JavaScript function as the argument. This can loop until any user-defined condition and can...
Read more >
Passing a function as an argument to another function in Python
When we call that function (with predicate(item) ), we pass a single argument to it and then check the truthiness of its return...
Read more >
robot.libraries package - Robot Framework API documentation
Displays the given messages in the log file as keyword arguments. ... By default retry_interval is the time to wait _after_ a keyword...
Read more >
Be Aware of the Traps of Condition Variables - Modernes C++
One thread prepares something and sends a notification another thread is waiting for. Why can't this be so dangerous?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found