jeudi 28 février 2019

Measure the load time of multiple web elements in Selenium

I would like to measure load times of multiple parts of a spinner element. HTML looks like this:

<div id="loading">
    <div id="spinner">
        <div class="spinner-icon"></div>
    </div>
    <p class="spinner-text">Please wait</p>
</div>

I'm interested which of the elements is loaded/displayed first? The icon? Text?

I was thinking of something like this:

Date t1 = new Date();
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("#loading")));
Date t2 = new Date();
long duration = t2.getTime() - t1.getTime();

But, can I use intertwined waits? Can I do this in a single script?

Aucun commentaire:

Enregistrer un commentaire