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>
asked Aug 20, 2019 at 15:53

1 Answer 1

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
 {
 //
 }
}
answered Aug 20, 2019 at 16:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.