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}')