'How to fetch all the XHR's header data using python/selenium/robot framework
I need to fetch all the API's request URL from a web page while browsing it can anyone help me with this?
the aim is to compare the list of API which is being called and supposed to call
I tried using a driver.get_log("performance") selenium method but I am getting only .jpgs and png files
driver.get("https:<URL>")
logs = driver.get_log("performance")
# Opens a writable JSON file and writes the logs in it
with open("network_log.json", "w", encoding="utf-8") as f:
f.write("[")
# Iterates every logs and parses it using JSON
for log in logs:
network_log = json.loads(log["message"])["message"]
f.write(json.dumps(network_log)+",")
Solution 1:[1]
You can't. Selenium doesn't handle anything like that. You would need to use a proxy with selenium like browsermob or something else that would let you intercept all network requests.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | KaibutsuX |
