Después de cargar un archivo en el sitio web, el sitio web muestra una pantalla de carga. La pantalla de carga está arriba dependiendo del tamaño del archivo. Me gustaría medir la duración de la carga de la página. Soy principiante en jmeter y programación, así que no sé si hay una idea mucho mejor que la que tengo actualmente.
Esto es lo que tengo hasta ahora.
var node = implicitFind(pkg.By.xpath("//div[id]")); //xpath of the loading screen var increment = 1; while (node != null) { if (increment == 1) var before = new Date().getTime(); //gets current time of test increment++; } var after = new Date().getTime(); WDS.log.info('------- Time taken for loading screen = ' + (after - before) + ' ms'); /* The reason why I added an increment was so the before time can be recorded only on the first loop rather than every loop. The loop ends when xpath no longer exist, which is when the after time is recorded. */El problema con este código es que jmeter nunca rompe el ciclo, incluso si la condición es falsa. El xpath es de un texto que aparece cuando aparece la pantalla de carga. Por favor, ayuda si hay una mejor manera o si hay una falla en mi código actual. ¡Gracias a todos!
Es difícil decir qué está mal sin ver el código de la función de implicitFind , es posible que desee volver a visitarlo y verificar la visibilidad o invisibilidad del elemento, es decir, use la función WebElement.isDisplayed()
Más información: The WebDriver Sampler: Sus 10 preguntas principales respondidas
long startTime = System.currentTimeMillis(); driver.get("http://infoall.org"); new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("Calculate"))); long endTime = System.currentTimeMillis(); long totalTime = endTime - startTime; System.out.println("Total Page Load Time: " + totalTime + "milliseconds");