简体   繁体   中英

Unable to click on the submit button with xpath and classname using selenium webdriver

This is the html code :

...
<div class="span_3_of_4"> 
  <p class="text_popup"> Dont Have an Account? | 
    <a class="fancybox" href="#load_box">Signup</a> 
  </p> 
</div> 
<div class="span_1_of_4" align="center"> 
  <input class="button" type="submit" value="Submit"/> 
</div> 
</div> 
</form> 
</div> 
<script src="js/jquery.form.js" type="text/javascript"/>

Its a submit button. I am trying to automate a registration for using selenium webdriver. There are no ids or names as such for this button. Hence i tried with xpath (taken from firebug) .//*[@id='load_form']/div/div[2]/input and classname - button .

Yet the following error was being thrown Element is not currently visible and so may not be interacted withCommand duration or timeout: 428 milliseconds . Please suggest as to how can i ever overcome this error and be able to click on the "submit" button.

Selenium Version - 2.44

Try this one:

driver.findElement(By.xpath("//div[@id='load_box']/form[@id='load_form']//input[@class='button' and @type='submit']"))

Problem was that there are several form elements with "load_form" on the site and the first one is hidden! that's why you need a more specific xpath like the one above.

I encounter this issue a lot, and one thing that normally solves the problem is switching frames. With python I think it's something like driver.switch_to_frame('frame') I may be wrong there with the syntax but definitely try that out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM