Jump to content
UBot Underground

Solution? Wait For Element - If Not Showing Then... Else


Recommended Posts

Is there a solution to combine.. incase a website doesnt load properly or is offline...

 

Combing: wait for element and if else

 

example:

 

navigate to www.login.com

Wait for Element (innertext Login to shop up)

If innertext login not showing up

then navigate to www.login.com

else

click login

Edited by sazuka
Link to post
Share on other sites

yes the function you need is this

 

http://wiki.ubotstudio.com/wiki/Exists

 

here is some example code

 reset browser
load html("<div id=\"container\">
<p id=\"myId\"></p>
</div>


<script>

console.log(parseInt(Math.random() * 10))


function fillText()\{
randNum= parseInt(Math.random() * 10)
document.getElementById(\"myId\").textContent = randNum

if( randNum === 0)\{
  
  document.getElementById(\"container\").innerHTML = document.getElementById(\"container\").innerHTML + \"<br><p id = \'nowExists\'>should now stop waiting</p>\"
  
  
\}
  else\{
setTimeout(function()\{
  
  fillText()
\},2000)
  \}

\}
fillText()
</script>")
comment("waiting for 0 to appear,if does not within 15 seconds,go with plan b")
wait for element(<id="nowExists">,15,"Appear")
if($comparison($exists(<id="nowExists">),"=",$true)) {
    then {
        alert("exists")
    }
    else {
        alert("do something else")
    }
}
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...