1

Here is the the html code:

<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
  <head></head>
  <body class="- view-form">
    <div id="container"> </div>
    <script type="text/javascript">
      var sub_chart_path = "device";
      var is_dependency = false;
      var max_zoom_factor = 5;
      var image_name_base = "NHCTCC01";
    </script>
   </body>
 </html>

What I want is to locate the element inside the <script type="text/javascript">.
Can anybody tell me how it can be located?

3
  • Have you tried anything? Commented Jun 20, 2015 at 17:45
  • And what do you mean "Element inside the script type = "text/javascript"? Commented Jun 20, 2015 at 17:48
  • Selenium locates the web elements inside the web page. There are no web elements present inside the <script type="text/javascript"> Commented Jul 4, 2015 at 15:07

1 Answer 1

1

You need to use the execute_script with Javascript executor and get the variable in return

driver.execute_script("return sub_chart_path;")

Should print: device

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.