from selenium.webdriver.common.by import By
from selenium import webdriver
driver = webdriver.Chrome()
# Navigate to the page you want to test
driver.get('https://url.com')
driver.implicitly_wait(40)
# Start profiling
driver.execute_cdp_cmd('Performance.enable', {})
driver.execute_script("console.profile()")
# Do some actions on the page
driver.find_element(By.XPATH, " ").click()
driver.find_element(By.XPATH, " ").click()
# Stop profiling now
driver.execute_script("console.profileEnd()")
# Get the performance metrics
metrics = driver.execute_cdp_cmd('Performance.getMetrics', {})
# Parse the bottom-up call tree
for metric in metrics['metrics']:
print(metric)
driver.quit()
1条答案
按热度按时间bxpogfeg1#
您可以使用下面的代码来提取性能指标
这将像这样打印所有指标