TestProject Forum
Powered by leading experts in the test automation community

Beginner - trying to create a simple Website Loading okay test

Hello - I am new and just trying to do a simple test to verify that the website is loading okay and items are present.

In my thinking for testing, my steps include going to the page, the doing a series of actions to make sure certain items are either present, or visible before progressing - simple enough right?

When running the test, it doesn’t progress past the first verification and fails on this step with all web browsers:

Is DIV4 < Div > visible?

Is this the improper way to go about doing a simple website loading test? Or just to make sure all the elements of the page have loaded and are visible? Thanks for any help and direction.

Checking for elements in a page is a good way to verify that the website and everything else has loaded properly.
Does the DIV have that visibility property to check? What error are you receiving when the step fails? Can you check if other elements are visible with no issue?

Hey David - thanks for your reply - much appreciated.

I’m simply attempting to do a rollover on the main looping video that appears at the top of this page:

I double shift on that, then have tried doing a validation for both “is present” and “is visible” and both fail in the test.

The test report shows “Timeout occurred after 15000ms, waiting for element visibility: Element was not found”

Is doing a validation the wrong way to go about this? When rolling over with the mouse, it only identifies the element as a div and xpath: XPATH: //*[@id=‘jq-1587962844031-0’]/div/div/div/div/div/div/div[2]

Thanks again!

I tried the website, and then performing the ‘Is Visible’ validation as well.

The cause of the error you are receiving is caused by the web page constantly generating a new ID for the element you are checking each time the website is loaded.

So if for example, you record on the page using the XPATH:

and then execute the test, the ID will actually be changed, and the correct XPATH would be:
Causing the element to not be located during your test run and failing the step by timeout.

These ID’s are site generated, and we can’t change them, so a good idea in cases like this would be to use a different locator strategy, for example, generalizing the XPATH so it will still locate that specific element without being dependent on that ID.

You can use this XPATH to check if that video is visible:
This checks the ID, but it only checks if it contains the string jq, which we can see is a constant in the auto-generated ID’s the site creates.


Oh good to know. So in theory, if I’m checking multiple items on the page to make sure they load and are visible, I should just follow that format ( **//*[contains(@id,‘jq’) manually editing the xpath for each element?

** Also - just noticed after doing a couple additional tests… this is still errors for me and I’m seeing that the DIV is different each time. Once it will be DIV8, then DIV10, etc.

Is this DIV also changing on each page refresh?

Thanks again!

The XPATH I used is not a rule, it’s more of a suggestion, there are many ways to write a correct XPATH that will work on that specific page on that specific element, something like that might not work on other pages that will require a different kind of XPATH or will not have something unique to use to catch an element with.

Another thing, on that same page there might be elements with constant ID’s, such as the “What’s New” div on the right, and you’ll be able to use the XPATH from the recorder as you did before with no need to think about a specific XPATH, it’s very page dependent.

And about the div, I did not see anything like that, but in case you are seeing more issues like mentioned in this thread, it’s all about the locator strategy.