Java 如何使用WebDriver获取任何web应用程序前端的数据加载时间?

Java 如何使用WebDriver获取任何web应用程序前端的数据加载时间?,java,selenium,webdriver,Java,Selenium,Webdriver,我有一个网络应用程序&它有一些超链接是登录的。 我将单击一些链接&它将从数据库中获取一些数据 现在,我想计算在前端(使用Selenium WebDriver)获取数据所需的时间。稍后,我想在任何文件中为我单击的每个链接节省时间 TIA.在JMeter中使用Selenium Web驱动程序有一个很好的方法 你只需要一开始就打电话 WDS.sampleResult.sampleStart(); //captures sampler's start time 最后: WDS.sampleResult

我有一个网络应用程序&它有一些超链接是登录的。 我将单击一些链接&它将从数据库中获取一些数据

现在,我想计算在前端(使用Selenium WebDriver)获取数据所需的时间。稍后,我想在任何文件中为我单击的每个链接节省时间

TIA.

在JMeter中使用Selenium Web驱动程序有一个很好的方法

你只需要一开始就打电话

WDS.sampleResult.sampleStart(); //captures sampler's start time
最后:

WDS.sampleResult.sampleEnd();
它将捕获在示例中花费的时间。

在JMeter中使用Selenium Web驱动程序有一个简单的方法

你只需要一开始就打电话

WDS.sampleResult.sampleStart(); //captures sampler's start time
最后:

WDS.sampleResult.sampleEnd();

它将捕获样本中花费的时间。

创建一个方法来获取当前系统时间,并在selenium代码之前和之后调用它。差异将是执行所花费的时间。您可以使用以下方法获取当前时间

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class time {

    public static void main(){
        Calendar cal=Calendar.getInstance();
        SimpleDateFormat sdf= new  SimpleDateFormat("HH:mm:ss");
        System.out.println(sdf.format(cal.getTime()));
    }
}

创建一个方法来获取当前系统时间,并在selenium代码之前和之后调用它。差异将是执行所花费的时间。您可以使用以下方法获取当前时间

import java.text.SimpleDateFormat;
import java.util.Calendar;

public class time {

    public static void main(){
        Calendar cal=Calendar.getInstance();
        SimpleDateFormat sdf= new  SimpleDateFormat("HH:mm:ss");
        System.out.println(sdf.format(cal.getTime()));
    }
}

您可以获得所有
性能和网络统计信息,如
Chrome开发工具中所反映的
注入
JavaScript
,如下所示:

driver.get("http://www.google.com");
String scriptToExecute = "var network = performance.getEntries() || {}; return network;";
String netData = ((JavascriptExecutor)driver).executeScript(scriptToExecute).toString();
System.out.println(netData);
控制台输出:

[{redirectCount=0, encodedBodySize=218571, unloadEventEnd=0, responseEnd=3951.465, domainLookupEnd=2665.135, unloadEventStart=0, domContentLoadedEventStart=4213.63, type=navigate, decodedBodySize=218571, duration=8751.54, redirectStart=0, connectEnd=3116.0650000000005, toJSON={}, requestStart=3119.46, startTime=0, fetchStart=3951.855, domContentLoadedEventEnd=4222.57, entryType=navigation, workerStart=0, responseStart=3280.1150000000002, domInteractive=4213.565, domComplete=8742.91, domainLookupStart=2665.135, redirectEnd=0, transferSize=226167, connectStart=2665.135, loadEventStart=8743.550000000001, secureConnectionStart=2755.7250000000004, name=http://www.google.com/, nextHopProtocol=h2, initiatorType=navigation, loadEventEnd=8751.54}, {encodedBodySize=3123, entryType=resource, responseEnd=4204.990000000001, workerStart=0, responseStart=4074.295, domainLookupEnd=3983.2650000000003, domainLookupStart=3983.2650000000003, redirectEnd=0, decodedBodySize=3123, duration=221.72500000000036, transferSize=3291, redirectStart=0, connectEnd=3983.2650000000003, toJSON={}, connectStart=3983.2650000000003, requestStart=3984.84, secureConnectionStart=0, name=https://www.google.co.in/logos/doodles/2017/holidays-2017-day-2-5240850203279360-s.png, startTime=3983.2650000000003, fetchStart=3983.2650000000003, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=0, entryType=resource, responseEnd=4704.6, workerStart=0, responseStart=0, domainLookupEnd=0, domainLookupStart=0, redirectEnd=0, decodedBodySize=0, duration=699.1949999999997, transferSize=0, redirectStart=0, connectEnd=0, toJSON={}, connectStart=0, requestStart=0, secureConnectionStart=0, name=https://ssl.gstatic.com/gb/images/i1_1967ca6a.png, startTime=4005.4050000000007, fetchStart=4005.4050000000007, nextHopProtocol=h2, initiatorType=css}, {encodedBodySize=23564, entryType=resource, responseEnd=4216.465, workerStart=0, responseStart=4119.075000000001, domainLookupEnd=4029.1900000000005, domainLookupStart=4029.1900000000005, redirectEnd=0, decodedBodySize=65725, duration=187.27499999999964, transferSize=23713, redirectStart=0, connectEnd=4029.1900000000005, toJSON={}, connectStart=4029.1900000000005, requestStart=4030.8600000000006, secureConnectionStart=0, name=https://www.google.co.in/logos/2016/slideshow/slideshow.15.js, startTime=4029.1900000000005, fetchStart=4029.1900000000005, nextHopProtocol=h2, initiatorType=script}, {duration=0, entryType=paint, toJSON={}, name=first-paint, startTime=4031.395000000001}, {duration=0, entryType=paint, toJSON={}, name=first-contentful-paint, startTime=4031.395000000001}, {encodedBodySize=0, entryType=resource, responseEnd=5181.595, workerStart=0, responseStart=5179.5, domainLookupEnd=4213.19, domainLookupStart=4213.19, redirectEnd=0, decodedBodySize=0, duration=968.4050000000007, transferSize=42, redirectStart=0, connectEnd=4213.19, toJSON={}, connectStart=4213.19, requestStart=4214.135, secureConnectionStart=0, name=https://www.google.co.in/gen_204?s=webaft&atyp=csi&ei=IcpAWvrYO5WcvQS6m7nQBw&rt=wsrt.3973,aft.239,prt.239, startTime=4213.19, fetchStart=4213.19, nextHopProtocol=h2, initiatorType=beacon}, {encodedBodySize=144968, entryType=resource, responseEnd=5178.63, workerStart=0, responseStart=4361.610000000001, domainLookupEnd=4225.935, domainLookupStart=4225.935, redirectEnd=0, decodedBodySize=422973, duration=952.6949999999997, transferSize=145177, redirectStart=0, connectEnd=4225.935, toJSON={}, connectStart=4225.935, requestStart=4245.030000000001, secureConnectionStart=0, name=https://www.google.co.in/xjs/_/js/k=xjs.s.en.wVFdvIGaPg4.O/m=sx,c,sb,cdos,cr,elog,hsm,jsa,r,d,csi/am=wCL0eMEDkP8PgSLRFRwWLA0wDA0/rt=j/d=1/t=zcms/rs=ACT90oFcejEpsXZHVqCUi53rHKPUdHFGrA, startTime=4225.935, fetchStart=4225.935, nextHopProtocol=h2, initiatorType=script}, {encodedBodySize=0, entryType=resource, responseEnd=5198.755, workerStart=0, responseStart=0, domainLookupEnd=0, domainLookupStart=0, redirectEnd=0, decodedBodySize=0, duration=773.1800000000003, transferSize=0, redirectStart=0, connectEnd=0, toJSON={}, connectStart=0, requestStart=0, secureConnectionStart=0, name=https://www.gstatic.com/og/_/js/k=og.og2.en_US.LzK9bE9r_qo.O/rt=j/m=def/exm=in,fot/d=1/ed=1/rs=AA2YrTvGrVgDnAbvldCsR-LVadyTgN-6Lw, startTime=4425.575, fetchStart=4425.575, nextHopProtocol=h2, initiatorType=script}, {encodedBodySize=30130, entryType=resource, responseEnd=5490.6050000000005, workerStart=0, responseStart=5434.985000000001, domainLookupEnd=5306.4, domainLookupStart=5306.4, redirectEnd=0, decodedBodySize=92899, duration=184.20500000000084, transferSize=30229, redirectStart=0, connectEnd=5306.4, toJSON={}, connectStart=5306.4, requestStart=5337.08, secureConnectionStart=0, name=https://www.google.co.in/xjs/_/js/k=xjs.s.en.wVFdvIGaPg4.O/m=d3l,udlg,aa,abd,async,dvl,foot,fpe,ipv6,lu,m,mu,sf,sonic,spch/am=wCL0eMEDkP8PgSLRFRwWLA0wDA0/exm=sx,c,sb,cdos,cr,elog,hsm,jsa,r,d,csi/rt=j/d=1/ed=1/t=zcms/rs=ACT90oFcejEpsXZHVqCUi53rHKPUdHFGrA?xjs=s1, startTime=5306.4, fetchStart=5306.4, nextHopProtocol=h2, initiatorType=script}, {encodedBodySize=0, entryType=resource, responseEnd=5901.43, workerStart=0, responseStart=0, domainLookupEnd=0, domainLookupStart=0, redirectEnd=0, decodedBodySize=0, duration=594.165, transferSize=0, redirectStart=0, connectEnd=0, toJSON={}, connectStart=0, requestStart=0, secureConnectionStart=0, name=https://www.google.com/textinputassistant/tia.png, startTime=5307.265, fetchStart=5307.265, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=850921, entryType=resource, responseEnd=8078.945000000001, workerStart=0, responseStart=5515.185, domainLookupEnd=5307.5, domainLookupStart=5307.5, redirectEnd=0, decodedBodySize=850921, duration=2771.4450000000006, transferSize=851491, redirectStart=0, connectEnd=5307.5, toJSON={}, connectStart=5307.5, requestStart=5338.195000000001, secureConnectionStart=0, name=https://www.google.co.in/logos/doodles/2017/holidays-2017-day-2-5240850203279360-5709068098338816-ssw.png, startTime=5307.5, fetchStart=5307.5, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=12361, entryType=resource, responseEnd=5513.750000000001, workerStart=0, responseStart=5499.31, domainLookupEnd=5307.675, domainLookupStart=5307.675, redirectEnd=0, decodedBodySize=12361, duration=206.07500000000073, transferSize=12471, redirectStart=0, connectEnd=5307.675, toJSON={}, connectStart=5307.675, requestStart=5338.285000000001, secureConnectionStart=0, name=https://www.google.co.in/logos/2016/slideshow/main-sprite-3.png, startTime=5307.675, fetchStart=5307.675, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=0, entryType=resource, responseEnd=5803.495000000001, workerStart=0, responseStart=0, domainLookupEnd=0, domainLookupStart=0, redirectEnd=0, decodedBodySize=0, duration=459.420000000001, transferSize=0, redirectStart=0, connectEnd=0, toJSON={}, connectStart=0, requestStart=0, secureConnectionStart=0, name=https://apis.google.com/_/scs/abc-static/_/js/k=gapi.gapi.en.yoTdpQipo6s.O/m=gapi_iframes,googleapis_client,plusone/rt=j/sv=1/d=1/ed=1/am=AAE/rs=AHpOoo9_VhuRoUovwpPPf5LqLZd-dmCnxw/cb=gapi.loaded_0, startTime=5344.075, fetchStart=5344.075, nextHopProtocol=h2, initiatorType=script}, {encodedBodySize=0, entryType=resource, responseEnd=8078.380000000001, workerStart=0, responseStart=8077.755, domainLookupEnd=6182.910000000001, domainLookupStart=6182.910000000001, redirectEnd=0, decodedBodySize=0, duration=1895.4700000000003, transferSize=40, redirectStart=0, connectEnd=6182.910000000001, toJSON={}, connectStart=6182.910000000001, requestStart=6183.765, secureConnectionStart=0, name=https://www.google.co.in/gen_204?atyp=i&ct=&cad=udla=1&ei=IcpAWvrYO5WcvQS6m7nQBw&di=2369&lt=-137922&ln=171221&zx=1514195497586, startTime=6182.910000000001, fetchStart=6182.910000000001, nextHopProtocol=h2, initiatorType=beacon}, {encodedBodySize=250301, entryType=resource, responseEnd=8727.245, workerStart=0, responseStart=8197.060000000001, domainLookupEnd=8104.39, domainLookupStart=8104.39, redirectEnd=0, decodedBodySize=250301, duration=622.8550000000005, transferSize=250500, redirectStart=0, connectEnd=8104.39, toJSON={}, connectStart=8104.39, requestStart=8106.290000000001, secureConnectionStart=0, name=https://www.google.co.in/logos/doodles/2017/holidays-2017-day-2-5240850203279360-5681717746597888-ssw.png, startTime=8104.39, fetchStart=8104.39, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=0, entryType=resource, responseEnd=8742.07, workerStart=0, responseStart=8741.205, domainLookupEnd=8104.6500000000015, domainLookupStart=8104.6500000000015, redirectEnd=0, decodedBodySize=0, duration=637.4199999999983, transferSize=40, redirectStart=0, connectEnd=8104.6500000000015, toJSON={}, connectStart=8104.6500000000015, requestStart=8106.845, secureConnectionStart=0, name=https://www.google.co.in/gen_204?atyp=i&ct=doodle&cad=d:68329420,c:0,e:1,t:-1,m:0,w:1,o:_&ei=IcpAWvrYO5WcvQS6m7nQBw&zx=1514195499507, startTime=8104.6500000000015, fetchStart=8104.6500000000015, nextHopProtocol=h2, initiatorType=img}]
注意:输出为
字符串
您可以提取任何参数值并进一步使用它

  • unloadEventStart
  • domContentLoadedEventStart
    domContentLoadedEventEnd
  • 持续时间
  • requestStart
  • fetchStart
  • 响应启动
    响应启动
  • connectStart
    connectEnd
  • 加载事件开始
    加载事件结束
  • secureConnectionStart

您可以获得所有
性能和网络统计数据
,如
注入
所示,如下所示:

driver.get("http://www.google.com");
String scriptToExecute = "var network = performance.getEntries() || {}; return network;";
String netData = ((JavascriptExecutor)driver).executeScript(scriptToExecute).toString();
System.out.println(netData);
控制台输出:

[{redirectCount=0, encodedBodySize=218571, unloadEventEnd=0, responseEnd=3951.465, domainLookupEnd=2665.135, unloadEventStart=0, domContentLoadedEventStart=4213.63, type=navigate, decodedBodySize=218571, duration=8751.54, redirectStart=0, connectEnd=3116.0650000000005, toJSON={}, requestStart=3119.46, startTime=0, fetchStart=3951.855, domContentLoadedEventEnd=4222.57, entryType=navigation, workerStart=0, responseStart=3280.1150000000002, domInteractive=4213.565, domComplete=8742.91, domainLookupStart=2665.135, redirectEnd=0, transferSize=226167, connectStart=2665.135, loadEventStart=8743.550000000001, secureConnectionStart=2755.7250000000004, name=http://www.google.com/, nextHopProtocol=h2, initiatorType=navigation, loadEventEnd=8751.54}, {encodedBodySize=3123, entryType=resource, responseEnd=4204.990000000001, workerStart=0, responseStart=4074.295, domainLookupEnd=3983.2650000000003, domainLookupStart=3983.2650000000003, redirectEnd=0, decodedBodySize=3123, duration=221.72500000000036, transferSize=3291, redirectStart=0, connectEnd=3983.2650000000003, toJSON={}, connectStart=3983.2650000000003, requestStart=3984.84, secureConnectionStart=0, name=https://www.google.co.in/logos/doodles/2017/holidays-2017-day-2-5240850203279360-s.png, startTime=3983.2650000000003, fetchStart=3983.2650000000003, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=0, entryType=resource, responseEnd=4704.6, workerStart=0, responseStart=0, domainLookupEnd=0, domainLookupStart=0, redirectEnd=0, decodedBodySize=0, duration=699.1949999999997, transferSize=0, redirectStart=0, connectEnd=0, toJSON={}, connectStart=0, requestStart=0, secureConnectionStart=0, name=https://ssl.gstatic.com/gb/images/i1_1967ca6a.png, startTime=4005.4050000000007, fetchStart=4005.4050000000007, nextHopProtocol=h2, initiatorType=css}, {encodedBodySize=23564, entryType=resource, responseEnd=4216.465, workerStart=0, responseStart=4119.075000000001, domainLookupEnd=4029.1900000000005, domainLookupStart=4029.1900000000005, redirectEnd=0, decodedBodySize=65725, duration=187.27499999999964, transferSize=23713, redirectStart=0, connectEnd=4029.1900000000005, toJSON={}, connectStart=4029.1900000000005, requestStart=4030.8600000000006, secureConnectionStart=0, name=https://www.google.co.in/logos/2016/slideshow/slideshow.15.js, startTime=4029.1900000000005, fetchStart=4029.1900000000005, nextHopProtocol=h2, initiatorType=script}, {duration=0, entryType=paint, toJSON={}, name=first-paint, startTime=4031.395000000001}, {duration=0, entryType=paint, toJSON={}, name=first-contentful-paint, startTime=4031.395000000001}, {encodedBodySize=0, entryType=resource, responseEnd=5181.595, workerStart=0, responseStart=5179.5, domainLookupEnd=4213.19, domainLookupStart=4213.19, redirectEnd=0, decodedBodySize=0, duration=968.4050000000007, transferSize=42, redirectStart=0, connectEnd=4213.19, toJSON={}, connectStart=4213.19, requestStart=4214.135, secureConnectionStart=0, name=https://www.google.co.in/gen_204?s=webaft&atyp=csi&ei=IcpAWvrYO5WcvQS6m7nQBw&rt=wsrt.3973,aft.239,prt.239, startTime=4213.19, fetchStart=4213.19, nextHopProtocol=h2, initiatorType=beacon}, {encodedBodySize=144968, entryType=resource, responseEnd=5178.63, workerStart=0, responseStart=4361.610000000001, domainLookupEnd=4225.935, domainLookupStart=4225.935, redirectEnd=0, decodedBodySize=422973, duration=952.6949999999997, transferSize=145177, redirectStart=0, connectEnd=4225.935, toJSON={}, connectStart=4225.935, requestStart=4245.030000000001, secureConnectionStart=0, name=https://www.google.co.in/xjs/_/js/k=xjs.s.en.wVFdvIGaPg4.O/m=sx,c,sb,cdos,cr,elog,hsm,jsa,r,d,csi/am=wCL0eMEDkP8PgSLRFRwWLA0wDA0/rt=j/d=1/t=zcms/rs=ACT90oFcejEpsXZHVqCUi53rHKPUdHFGrA, startTime=4225.935, fetchStart=4225.935, nextHopProtocol=h2, initiatorType=script}, {encodedBodySize=0, entryType=resource, responseEnd=5198.755, workerStart=0, responseStart=0, domainLookupEnd=0, domainLookupStart=0, redirectEnd=0, decodedBodySize=0, duration=773.1800000000003, transferSize=0, redirectStart=0, connectEnd=0, toJSON={}, connectStart=0, requestStart=0, secureConnectionStart=0, name=https://www.gstatic.com/og/_/js/k=og.og2.en_US.LzK9bE9r_qo.O/rt=j/m=def/exm=in,fot/d=1/ed=1/rs=AA2YrTvGrVgDnAbvldCsR-LVadyTgN-6Lw, startTime=4425.575, fetchStart=4425.575, nextHopProtocol=h2, initiatorType=script}, {encodedBodySize=30130, entryType=resource, responseEnd=5490.6050000000005, workerStart=0, responseStart=5434.985000000001, domainLookupEnd=5306.4, domainLookupStart=5306.4, redirectEnd=0, decodedBodySize=92899, duration=184.20500000000084, transferSize=30229, redirectStart=0, connectEnd=5306.4, toJSON={}, connectStart=5306.4, requestStart=5337.08, secureConnectionStart=0, name=https://www.google.co.in/xjs/_/js/k=xjs.s.en.wVFdvIGaPg4.O/m=d3l,udlg,aa,abd,async,dvl,foot,fpe,ipv6,lu,m,mu,sf,sonic,spch/am=wCL0eMEDkP8PgSLRFRwWLA0wDA0/exm=sx,c,sb,cdos,cr,elog,hsm,jsa,r,d,csi/rt=j/d=1/ed=1/t=zcms/rs=ACT90oFcejEpsXZHVqCUi53rHKPUdHFGrA?xjs=s1, startTime=5306.4, fetchStart=5306.4, nextHopProtocol=h2, initiatorType=script}, {encodedBodySize=0, entryType=resource, responseEnd=5901.43, workerStart=0, responseStart=0, domainLookupEnd=0, domainLookupStart=0, redirectEnd=0, decodedBodySize=0, duration=594.165, transferSize=0, redirectStart=0, connectEnd=0, toJSON={}, connectStart=0, requestStart=0, secureConnectionStart=0, name=https://www.google.com/textinputassistant/tia.png, startTime=5307.265, fetchStart=5307.265, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=850921, entryType=resource, responseEnd=8078.945000000001, workerStart=0, responseStart=5515.185, domainLookupEnd=5307.5, domainLookupStart=5307.5, redirectEnd=0, decodedBodySize=850921, duration=2771.4450000000006, transferSize=851491, redirectStart=0, connectEnd=5307.5, toJSON={}, connectStart=5307.5, requestStart=5338.195000000001, secureConnectionStart=0, name=https://www.google.co.in/logos/doodles/2017/holidays-2017-day-2-5240850203279360-5709068098338816-ssw.png, startTime=5307.5, fetchStart=5307.5, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=12361, entryType=resource, responseEnd=5513.750000000001, workerStart=0, responseStart=5499.31, domainLookupEnd=5307.675, domainLookupStart=5307.675, redirectEnd=0, decodedBodySize=12361, duration=206.07500000000073, transferSize=12471, redirectStart=0, connectEnd=5307.675, toJSON={}, connectStart=5307.675, requestStart=5338.285000000001, secureConnectionStart=0, name=https://www.google.co.in/logos/2016/slideshow/main-sprite-3.png, startTime=5307.675, fetchStart=5307.675, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=0, entryType=resource, responseEnd=5803.495000000001, workerStart=0, responseStart=0, domainLookupEnd=0, domainLookupStart=0, redirectEnd=0, decodedBodySize=0, duration=459.420000000001, transferSize=0, redirectStart=0, connectEnd=0, toJSON={}, connectStart=0, requestStart=0, secureConnectionStart=0, name=https://apis.google.com/_/scs/abc-static/_/js/k=gapi.gapi.en.yoTdpQipo6s.O/m=gapi_iframes,googleapis_client,plusone/rt=j/sv=1/d=1/ed=1/am=AAE/rs=AHpOoo9_VhuRoUovwpPPf5LqLZd-dmCnxw/cb=gapi.loaded_0, startTime=5344.075, fetchStart=5344.075, nextHopProtocol=h2, initiatorType=script}, {encodedBodySize=0, entryType=resource, responseEnd=8078.380000000001, workerStart=0, responseStart=8077.755, domainLookupEnd=6182.910000000001, domainLookupStart=6182.910000000001, redirectEnd=0, decodedBodySize=0, duration=1895.4700000000003, transferSize=40, redirectStart=0, connectEnd=6182.910000000001, toJSON={}, connectStart=6182.910000000001, requestStart=6183.765, secureConnectionStart=0, name=https://www.google.co.in/gen_204?atyp=i&ct=&cad=udla=1&ei=IcpAWvrYO5WcvQS6m7nQBw&di=2369&lt=-137922&ln=171221&zx=1514195497586, startTime=6182.910000000001, fetchStart=6182.910000000001, nextHopProtocol=h2, initiatorType=beacon}, {encodedBodySize=250301, entryType=resource, responseEnd=8727.245, workerStart=0, responseStart=8197.060000000001, domainLookupEnd=8104.39, domainLookupStart=8104.39, redirectEnd=0, decodedBodySize=250301, duration=622.8550000000005, transferSize=250500, redirectStart=0, connectEnd=8104.39, toJSON={}, connectStart=8104.39, requestStart=8106.290000000001, secureConnectionStart=0, name=https://www.google.co.in/logos/doodles/2017/holidays-2017-day-2-5240850203279360-5681717746597888-ssw.png, startTime=8104.39, fetchStart=8104.39, nextHopProtocol=h2, initiatorType=img}, {encodedBodySize=0, entryType=resource, responseEnd=8742.07, workerStart=0, responseStart=8741.205, domainLookupEnd=8104.6500000000015, domainLookupStart=8104.6500000000015, redirectEnd=0, decodedBodySize=0, duration=637.4199999999983, transferSize=40, redirectStart=0, connectEnd=8104.6500000000015, toJSON={}, connectStart=8104.6500000000015, requestStart=8106.845, secureConnectionStart=0, name=https://www.google.co.in/gen_204?atyp=i&ct=doodle&cad=d:68329420,c:0,e:1,t:-1,m:0,w:1,o:_&ei=IcpAWvrYO5WcvQS6m7nQBw&zx=1514195499507, startTime=8104.6500000000015, fetchStart=8104.6500000000015, nextHopProtocol=h2, initiatorType=img}]
注意:输出为
字符串
您可以提取任何参数值并进一步使用它

  • unloadEventStart
  • domContentLoadedEventStart
    domContentLoadedEventEnd
  • 持续时间
  • requestStart
  • fetchStart
  • 响应启动
    响应启动
  • connectStart
    connectEnd
  • 加载事件开始
    加载事件结束
  • secureConnectionStart

请试用您的代码。我不知道WebDriver是否有相关的API来实现这一点,或者我只能使用Java相关类,比如,在加载页面之前或之后获取系统时间&减去以获取加载时间。我想知道如果WebDriver有,最好的方法是什么。请试用您的代码。我不知道WebDriver是否有r要实现这一点,我必须使用与Java相关的类,比如,在加载页面之前或之后获取系统时间&减去以获取加载时间。我想知道如果WebDriver有,最好的方法是什么。我不想使用Jmeter。只需使用WebDriver和Java,我想计算每次单击后的加载时间。只想知道用于WebDriver和Java的e方法。但我给出了在selenium web Driver中捕获时间的方法。我明白了,我误解了。让我尝试一下,并向您更新。谢谢。我不想使用Jmeter。仅通过使用WebDriver和Java,我想计算每次单击后的加载时间。只想知道WebDrive使用的方法但是我给出了在SeleniumWebDriveRoh中捕获时间的方法,我明白了,我误解了。让我尝试一下并更新一下。谢谢。