What is the best way to measure the loading time of a "Loading Screen" page using Jmeter and Selenium?

Once a file is uploaded to the website, a loading screen appears depending on the file size. I am interested in measuring how long this loading screen remains active. As a novice in jmeter and programming, I'm unsure if there's a more efficient method than what I currently have.

Here is my current approach:

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. 
*/

The problem with this code is that jmeter does not break the loop even when the condition is false. The xpath corresponds to a text displayed during the loading process. I would appreciate any help or suggestions for improving my code. Thank you!

Answer №2

long startTime = System.currentTimeMillis();

driver.get("http://example.com");
new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id("login")));

long endTime = System.currentTimeMillis();
long totalTime = endTime - startTime;

System.out.println("Page Load Time: " + totalTime + "ms");

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Achieving data synchronization and sequencing with AngularJS promises at a 1:1 ratio

Concern I am facing challenges with AngularJS promise synchronization and sequencing as my app expands across multiple controllers and services. In this scenario, I have an articles controller named ArticleController along with a related service named Art ...

When attempting to display an identical image on two distinct canvas elements in Angular 6

I am facing an issue where the image is only rendered on the second canvas instead of both canvases. I need assistance in finding a solution to render the same image on both canvases. Below is a screenshot demonstrating that the image is currently only re ...

An error was encountered when attempting to use the 'await' syntax in a useEffect() function that called axios.get()

To avoid using .then(..), I have switched to utilizing await. I am making a call to a function that includes an Axios request and returns the data as response.data after awaiting for it. My functional component has a useEffect that is meant to initialize a ...

Positioning a designated div directly above a designated spot on the canvas

I'm grappling with a challenge in my game where the canvas handles most of the animation, but the timer for the game resides outside the canvas in a separate div. I've been struggling to center the timer around the same focal point as the squares ...

Troubleshooting Async Issues in Node.js

I am encountering an issue with my node.js app structure, which is as follows: async.forever( function(callback) { async.series([ function(callback) { SomeFunction1(function(err, results) { if (err) callback(err); ...

Text input in Bootstrap not reaching full width

Trying to achieve a Bootstrap textfield embedded in a panel that spans 100% of the remaining space-width within the panel. However, this is the result obtained: The blue border represents the edge of the panel. Below is the code being used: <div clas ...

Guide on selecting the element in Selenium and Python that has an svg tag with the attribute focusable="false"

I'm a beginner in using Selenium with Python. Currently, I am facing an issue while trying to click on a specific element (which is a close button). <div class="CloseButton_Background__27knc"> <svg class="MuiSvgIcon-root C ...

Ways to create a new line in JSX using a JavaScript string

My JSX contains a string that I utilize: const message = 'Hello World'; and in my JSX: <p>{message}</p> Is there a way to start a new line from World? The desired output is: Hello World ...

Receive axios responses in the exact order as the requests for efficient search functionality

Currently, I am working on integrating a search feature in React Native using axios. For the search functionality, I am incorporating debounce from lodash to control the number of requests being sent. However, there is a concern about receiving responses ...

Is there a method to redirect the entire webpage using a script within an iframe?

I am seeking a solution to redirect the entire window to another page when clicking a link inside an iframe. It is important that it redirects the entire window, not just the iframe itself. Is this even possible? I would prefer to implement this in JavaSc ...

Shorten the content while preserving the HTML using JavaScript

When printing a string containing HTML links, I need to truncate the visible text while preserving the link structure. Simply using a substring method would disrupt the HTML tags in the string. I aim to display only 100 characters but also remove any inc ...

Navigating the Angular Controller life cycle

I have set up my application states using ui-router: $stateProvider .state('app', { abstract: true, views: { 'nav@': { templateUrl: 'app/navbar.html', controller: 'NavbarController' ...

The value of req.headers('Authorization') has not been defined

I'm experiencing difficulty with my code as the token is coming back as undefined. Here is the frontend section: export const fetchUser = async (token: any) => { const res = await axios.post('/user/getuser', { headers ...

Implementing jsGrid: Appending a row with JSON information

Is there a way to dynamically insert a row in jsGrid? I found some helpful code examples at https://github.com/tabalinas/jsgrid/blob/master/demos/db.js ...

Can one retrieve a catalog of Windows Updates that have been installed by utilizing node.js?

Currently, I am working on a JavaScript/Node.js project where I am seeking to retrieve a comprehensive list of all installed windows updates, similar to how it is done using the C# WUAPI 2.0 Type Library. I have attempted utilizing WMI calls (specifically ...

Tips for presenting JSON date in JavaScript using Google Chart

I am in urgent need of assistance with this issue. I am trying to display the date from PHP JSON data retrieved from my database in a Google Chart using JavaScript. Below is the PHP code snippet: $data_points = array(); while($row = mysqli_fetch_array($r ...

Arrangement of watch attachment and $timeout binding

I recently encountered a component code that sets the HTML content using $scope.htmlContent = $sce.trustAsHtml(content). Subsequently, it calls a function within a $timeout to search for an element inside that content using $element.find('.stuff' ...

Sharing state between components in NextJS involves using techniques like Context API, passing

I am trying to pass state between pages in Next.js. In my App.js, I have wrapped it in a context provider like this: import { useRouter } from 'next/router' import { ClickProvider } from '../context/clickContext' function MyApp({ Compo ...

A JavaScript regular expression for identifying IMDB URLs

Could someone please help me identify the issue with this JavaScript code? "http://www.imdb.com/title/tt2618986/".match("~http://(?:.*\.|.*)imdb.com/(?:t|T)itle(?:\?|/)(..\d+)~i"); I tested it here https://regex101.com/r/yT7bG4/1 and it wo ...

Encountering an Uncaught Error: MyModule type lacks the 'ɵmod' property

I am currently working on developing a custom module to store all my UI components. It is essential that this module is compatible with Angular 10 and above. Here is the package.json file for my library: { "name": "myLibModule", &qu ...