我正在尝试点击div
标记中的元素。以下是HTML:
<div id="btnCreditCard" class="paymentBtn creditcard" style="display: block;">
<a class="button button-primary button-override has-icon-right" href="javascript:Biz.GlobalShopping.CheckOut.continueToReview(1);">
<i class="button-icon-left"></i>Continue To Order Review<i class="button-icon-right fa fa-caret-right"></i>
</a>
</div>
我已经尝试了所有可能的事情,我知道甚至jQuery注入和点击但仍然没有vail。我到目前为止尝试的代码:
#m = driver.find_element_by_css_selector('#btnCreditCard > a')
#m = driver.find_elements_by_xpath('//*[@id="btnCreditCard"]/a/i[1]')
#x = driver.find_element_by_xpath('//*[@id="btnCreditCard"]/a')
#element = WebDriverWait(driver, 10).until(lambda driver : x).click()
#driver.execute_script('( $("#btnCreditCard").hide() );')
#driver.execute_script('( $("#btnCreditCard").show() );')
#driver.execute_script('eval($("#btnCreditCard > a").attr("href")) ;')
#driver.execute_script('eval("Biz.GlobalShopping.CheckOut.continueToReview(1)") ;')
#driver.execute_script('$("#btnCreditCard > a")[0].click();')
我遇到以下异常:
Exception Message: u'Element is not currently visible and so may not be interacted with' ; Stacktrace:
at fxdriver.preconditions.visible (file:///var/folders/4B/4Bd6e77uH-uNGxBS-xhds++++TI/-Tmp-/tmp13jGXK/extensions/fxdriver@googlecode.com/components/command-processor.js:8936:5)
at DelayedCommand.prototype.checkPreconditions_ (file:///var/folders/4B/4Bd6e77uH-uNGxBS-xhds++++TI/-Tmp-/tmp13jGXK/extensions/fxdriver@googlecode.com/components/command-processor.js:11595:1)
at DelayedCommand.prototype.executeInternal_/h (file:///var/folders/4B/4Bd6e77uH-uNGxBS-xhds++++TI/-Tmp-/tmp13jGXK/extensions/fxdriver@googlecode.com/components/command-processor.js:11612:11)
at DelayedCommand.prototype.executeInternal_ (file:///var/folders/4B/4Bd6e77uH-uNGxBS-xhds++++TI/-Tmp-/tmp13jGXK/extensions/fxdriver@googlecode.com/components/command-processor.js:11617:7)
at DelayedCommand.prototype.execute/< (file:///var/folders/4B/4Bd6e77uH-uNGxBS-xhds++++TI/-Tmp-/tmp13jGXK/extensions/fxdriver@googlecode.com/components/command-processor.js:11559:5)
Traceback (most recent call last):
File "/xx/Leo/xx/xxx", line 122, in addOrderFull
m = driver.find_element_by_xpath('//*[@id="btnCreditCard"]').click()
我正在使用Python2.7