-1

Maybe some can kindly help on the following issue. I need to click on element and then to get the data which went to server and what is and endpoint in JSON format. The URL doesn't change only the API endpoint.

wait.until(EC.url_contains('/somedata/'))
    time.sleep(5)

    target_url = 'https://urlname'
    logs = driver.get_log("performance")
    for log in logs:
        message = log["message"]
        if "Network.responseReceived" in message:
            params = json.loads(message)["message"].get("params")
            if params:
                response = params.get("response")
                if response:
                     if response and target_url in response["url"]:
                        body = driver.execute_cdp_cmd('Network.getResponseBody', {'requestId': params["requestId"]})
                        logger.info(f'{body}')
                        print(f'{body}')

1 Answer 1

0

Selenium is not a tool to test internal websites API.

However, there is a python module called selenium-wire that can help you listen the network traffic between the front-end (browser) and the back-end (web server).

See also this post.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.