Forum Discussion

gilad's avatar
gilad
Occasional Visitor
3 years ago

Screenshots - Selenium JSON script - don't fail when element doesn't exist

Hi,

 

I'm running a screenshots test with a Selenium JSON script (added below).

On some browsers, that element doesn't exist at the time of step execution.

Those browser results show "Screenshot Failed - Selenium Script Error".

The question is how I can configure the script not to fail in that case, so that I still get a screenshot result.

 

Thanks.

 

script:

 

{
  "type": "script",
  "seleniumVersion": "2",
  "formatVersion": 2,
  "steps": [
    {
      "type": "clickElement",
      "locator": {
        "type": "css selector",
        "value": ".cmplz-close"
      }
    }
  ],
  "data": {
    "configs": {},
    "source": "none"
  },
  "inputs": [],
  "timeoutSeconds": 60
}

 

  • Hi gilad@!

     

    Is the object you are referring to sometimes not present at all? Or does the script just need to pause sometimes while the element loads? 

     

    If there are times where it will not be present at all, unfortunately there is not a lot we can do there. These JSON scripts really don't allow for any type of logic or conditions to handle events like this. Though if it's just a matter of waiting, we can use timeouts, but I see you are already using that so I assume that is not applicable. 

     

     

  • Hi gilad@!

     

    Is the object you are referring to sometimes not present at all? Or does the script just need to pause sometimes while the element loads? 

     

    If there are times where it will not be present at all, unfortunately there is not a lot we can do there. These JSON scripts really don't allow for any type of logic or conditions to handle events like this. Though if it's just a matter of waiting, we can use timeouts, but I see you are already using that so I assume that is not applicable.