How to click a button created using <span> tag for Selenium webdriver?
<p>I have span tag which looks like a button on html tag </p>

<pre><code>    &lt;span class="middle"&gt;Next&lt;/span&gt;
</code></pre>

<p>I tried using </p>

<pre><code>    xpath=driver.findElement(By.xpath(".//*[@id='modal-actions-panel']/div[2]/a/span/span/span")); // by considering fixed id as reference
</code></pre>

<p>Using absolute </p>

<pre><code>xpath=driver.findElement(By.xpath("html/body/div[4]/div[2]/a/span/span/span"));  // took this from firebug
</code></pre>

<p>and Using </p>

<pre><code>driver.findElement(By.cssSelector("span[class='middle']"));
</code></pre>

<p>No success!! It is throwing below exception :</p>

<blockquote>
  <p>Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//span[contains(., \"Next\")]"}
      Command duration or timeout: 30.12 seconds
      For documentation on this error, please visit: <a href="http://seleniumhq.org/exceptions/no_such_element.html" rel="nofollow">http://seleniumhq.org/exceptions/no_such_element.html</a></p>
</blockquote>

<p>For all the ways I tried it is showing the same exception with change in selector details. Can someone please help me out in finding solution so that I can find Next button that is in span tag and click it.</p>

<p>Next button is in iFrame: Below is the part of html covering required span tag.</p>


    
    
    
    
    
    
    
    
    
    
    
    
    
    
    Next
    
    
    
    
    
    
    
    
    

<p>I also tried with :</p>

<pre><code>driver.switchTo().frame("iframe-applicationname_ModalDialog_0");
WebElement el = driver.findElement(By.cssSelector("span.middle"));
</code></pre>

<p>But throwing below error :</p>

<blockquote>
  <p>Caused by: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with</p>
</blockquote>

<p>Kindly let me know if needed something that I'm missing..</p>