Last active
December 21, 2019 09:23
-
-
Save AutomatedTester/272f35626d19acf64d4ddda990daafb8 to your computer and use it in GitHub Desktop.
Processor that goes through a debug log of puppeteer and gives a count of all the commands and events used
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import sys | |
def process(file_): | |
raw_lines = [] | |
with open(file_, "r") as f: | |
raw_lines = f.read() | |
lines = raw_lines.split('\n') | |
send = {} | |
recv = {} | |
for line in lines: | |
recv_group = re.search(r'puppeteer:protocol.+RECV.+"method":"(\w+\.\w+)"', line, re.M|re.I) | |
send_group = re.search(r'puppeteer:protocol.+SEND.+"method":"(\w+\.\w+)"', line, re.M|re.I) | |
if recv_group: | |
kv = recv_group.group(1) | |
nm = recv.get(kv) | |
if nm: | |
recv[kv] = nm + 1 | |
else: | |
recv[kv] = 1 | |
if send_group: | |
kv = send_group.group(1) | |
nm = send.get(kv) | |
if nm: | |
send[kv] = nm + 1 | |
else: | |
send[kv] = 1 | |
print("The following events have been received from the browser during the run with their count") | |
print(recv) | |
print("=====") | |
print("The following commands have been sent from the browser during the run with their count") | |
print(send) | |
if __name__ == "__main__": | |
process(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment