[英]Unable to click on the submit button with xpath and classname using selenium webdriver
這是html代碼:
...
<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"/>
它是一個提交按鈕。 我正在嘗試自動使用硒Web驅動程序進行注冊。 此按鈕沒有ID或名稱。 因此,我嘗試使用xpath(取自firebug) .//*[@id='load_form']/div/div[2]/input
和classname
- button
。
但是引發了以下錯誤: Element is not currently visible and so may not be interacted withCommand duration or timeout: 428 milliseconds
。 請建議我如何克服此錯誤,然后單擊“提交”按鈕。
硒版本-2.44
試試這個:
driver.findElement(By.xpath("//div[@id='load_box']/form[@id='load_form']//input[@class='button' and @type='submit']"))
問題在於站點上有多個帶有“ load_form”的form
元素,而第一個元素被隱藏了! 這就是為什么您需要更具體的xpath的原因,例如上面的一個。
我經常遇到此問題,通常可以解決此問題的一件事是切換框架。 使用python我認為它類似於driver.switch_to_frame('frame')
我在語法上可能有誤,但可以嘗試一下
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.