1

I am running a selenium script on a web page. When the page shows a text I want the script to continue the loop. But when that text is missing I want the script to wait for X seconds before continuing and going to a new loop.

I have tried using assert and verify commands, wherein the script continues when the text is found but when the page doesn't show that text the script waits for the timeout (10 seconds) and then throws an error and continues anyway. But I need it to go into the "else" command where I have used "pause" so that the script waits before going ahead.

This is what the logs show: [error][ignored] Line 6: timeout reached when looking for element 'xpath=//*[@id="poll"]/div/div[3]/div/p'

This is the code:

 {
      "Command": "if_v2",
      "Target": "${!statusOK} == true",
      "Value": ""
    },
    {
      "Command": "assertElementPresent",
      "Target": "xpath=//*[@id=\"poll\"]/div/div[3]/div/p",
      "Value": "Your vote was counted."
    },
    {
      "Command": "else",
      "Target": "",
      "Value": ""
    },
    {
      "Command": "pause",
      "Target": "30000",
      "Value": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": ""
    },

Please help me fix this. Any command is fine. Just need to do 2 different things when the text is shown and when it's not shown. The page is very light so it loads in 1-2 seconds. So a timeout of 5 would also be enough. But instead of throwing error after timing out when it doesn't find the text, I want it to jump to "else".

2
  • there is no timeout actions in the script you added , it should fail immediatly how is it wait ing ? – PDHide Jan 29 at 20:51
  • i couldn't find if_v2 command in the documentation could you add proper project side file – PDHide Jan 29 at 20:52

Your Answer

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

Browse other questions tagged or ask your own question.