title: Python and Selenium To “execute_script” to solve “ElementNotVisibleException”
body: <p>I am using Selenium to save a webpage. The content of webpage will change once certain checkbox(s) are clicked. What I want is to click a checkbox then save the page content. (The checkboxes are controlled by JavaScript.)</p>
  
  <p>Firstly I used: </p>
  
  <pre><code>driver.find_element_by_name("keywords_here").click()
  </code></pre>
  
  <p>it ends with an error:</p>
  
  <pre><code>NoSuchElementException
  </code></pre>
  
  <p>then I tried “xpath” like, with implicit/explicit waiting:</p>
  
  <pre><code>URL = “the url”
  
  verificationErrors = []
  accept_next_alert = True
  
  aaa = driver.get(URL)
  driver.maximize_window()
  WebDriverWait(driver, 10)
  
  #driver.find_element_by_xpath(".//*[contains(text(), ' keywords_here')]").click()
  #Or: 
  
  driver.find_element_by_xpath("//label[contains(text(),' keywords_here')]/../input[@type='checkbox']").click()
  </code></pre>
  
  <p>it gives an error: </p>
  
  <pre><code>ElementNotVisibleException
  </code></pre>
  
  <p>Posts </p>
  
  <p><a href="https://stackoverflow.com/questions/6101461/how-to-force-selenium-to-click-on-element-which-is-not-currently-visible#">How to force Selenium WebDriver to click on element which is not currently visible?</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27927964/selenium-element-not-visible-exception">Selenium Element not visible exception</a></p>
  
  <p>suggest it should make the checkboxes visible before clicking, for example using:</p>
  
  <pre><code>execute_script
  </code></pre>
  
  <p>The question may sounds stupid, but how can I find out the proper sentence to “execute_script” the visibility of checkbox from the page source code?</p>
  
  <p>Besides that, is there another way?</p>
  
  <p>Thanks.</p>
  
  <p>by the way, the line html code looks like:</p>
  
  <pre><code>&lt;input type="checkbox" onclick="ComponentArt_HandleCheck(this,'p3',11);" name="keywords_here"&gt;
  </code></pre>
  
  <p>its xpath looks like:</p>
  
  <pre><code>//*[@id="TreeView1_item_11"]/tbody/tr/td[3]/input
  </code></pre>