0

I am automating a file upload on a web page. The point of my automation is to check if the file upload is taking longer than expected.

This is the hmtl for the progress upload bar banner:

<div _ngcontent-rqo-c295="" class="upload-box-title"> 
  "Uploading List: 0/0"
  <label _ngcontent-rqo-c295="" class="ui label mini right clear-label" style="margin-right: 1px;">CLEAR</label>
</div>

When the process is completed, the "uploading list" text will go from "0/0" (before uploading) to "0/1" while uploading 1 file, the only case i will be testing) to "1/1" , when the upload is completed.

I have 3 questions:

  • How can I check for the change in that text
  • How can I get the time between "0/0" and "1/1"?
  • Can I do an Assert with the time? Saying i know how long it should take when working properly and in case it takes longer it throws a warning?

Thank you for the help. I am coding in C# and Selenium. I am uploading the file with Process.Start("\upload.exe"). The .exe is a script done with AutoItX3.

0

How can I check for the change in that text

You can wait for the visibility of the text in a particular web element

WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.textToBePresentInElementLocated(myElement, "1/1"));

You can find the C# documentation here. enter image description here

How can I get the time between "0/0" and "1/1"?

You can use Stopwatch to get the current time.

var watch = System.Diagnostics.Stopwatch.StartNew();
performTheFileUpload();
watch.Stop();
var elapsedTime = watch.ElapsedMilliseconds;

Can I do an Assert with the time? Saying I know how long it should take when working properly and in case it takes longer it throws a warning?

Sure, watch.ElapsedMilliseconds is a long. You can assert against it as you do with any other long.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.