title: Watir::Browser#execute_script and "Element no longer valid"
body: <p>I'm writing some automation for a website of ours in Internet Explorer (it has to be IE :&lt; ) and I ran into some issues with execute_script. I need to move a vertical splitbar over 200px so it doesn't move certain elements off the page, making them unclickable. To do this I figured I would use the <code>Watir::Browser#execute_script</code> functionality. The idea would be to change the style tag to the correct coordinates. Unfortunately I haven't been able to get it to work due to "Element is no longer valid" errors. Here are the two cases I tried and their respective errors.</p>
  
  <p>First, I tried just getting the style attribute (the one I need to change) via a javascript script. </p>
  
  <pre><code>script = &lt;&lt;-JS
    return arguments[0].style
  JS
  
  browser.execute_script(script, aw.watir.div(class: 'x-vsplitbar'))
  </code></pre>
  
  <p>This gives me <code>Uncaught exception: Element is no longer valid</code></p>
  
  <p>I also tried changing the element's tag as well.</p>
  
  <pre><code>element = aw.watir.div(class: 'x-vsplitbar')
  style = element.style.gsub('200', '400')
  script = "return arguments[0].style = '#{style}'"
  browser.execute_script(script, element)
  </code></pre>
  
  <p>This just gave me a sweet error <code>JavaScript error (Selenium::WebDriver::Error::JavascriptError)</code></p>
  
  <p>The script in this example comes out to:</p>
  
  <pre><code>return arguments[0].style = 'HEIGHT: 897px; WIDTH: 5px; POSITION: absolute; LEFT: 400px; TOP: 50px'
  </code></pre>
  
  <p>Not sure what I'm doing wrong here, I followed <a href="https://jkotests.wordpress.com/2013/07/10/changing-an-elements-attribute-value/" rel="nofollow">this</a> guide.</p>
  
  <p>Another solution would be to use Watir to simulate the dragging action needed but I couldn't figure out how to drag the bar to the right.</p>