0

As on the below I’m having a HTML page where it change the variable value at the run time.

So the java script is to change the isrendered variable to true after 10 seconds. Even after I inspect the HTML page source the original isrendered variable stays as false. That means it’s not actually changing the page source. But somehow after 10 seconds system identifies isrendered as true.

So is there any way to capture something like this using selenium.

<div class="full-height">
  Hello !
</div>

<script>
    var isrendered=false;

  setTimeout(function(){ isrendered =true; }, 10000);

</script>

1

I was able to read the variable name bu below code.

IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
string result = js.ExecuteScript("return isrendered").ToString();

So the code will be

public static void CheckForString()
{
    IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
    string result = js.ExecuteScript("return isrendered").ToString();

    if (result =="False")
    {
        Thread.Sleep(5000);
        CheckForString();
    }
    else
    {
        //
    }
}

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.