使用复合类Selenium时没有这样的元素

时间:2016-10-27 17:53:32

标签: python css selenium-webdriver

我正在开发Web UI自动化。我遇到了复合课。我用Google搜索并想出办法来做到这一点。但后来我面临着没有这样的元素异常。请帮助。

selenium.common.exceptions.NoSuchElementException: Message: no such element
 (Session info: chrome=52.0.2743.116)
 (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)

以下是我正在努力实现自动化的HTML代码片段

<div id="prefill-two-up" class="two-up">
<div id="prefill-graduation-date" style="display: block;">
<!-- end grad date -->
<!-- begin hs date range -->
<div id="prefill-hs-date-range" style="display:none">
<!-- end hs date range -->
<p class="action-space">
<a class="btn action prefill-hs-done" data-hs-num="1" href="#">Done</a>
 or 
<a class="link-alt cancel-button-hs" data-hs-num="1" href="#">Cancel</a>
</p>
<div class="complete-form-error error" style="">
<span id="invalid-prefill-hs-form-open" class="message ui-state-error" style="display:none;">
</div>

我尝试使用CSS但失败了。

self.driver.find_element_by_css_selector("p.action-space a.btn.action.prefill-hs-done").click()

还试过

 time.wait(10)
self.driver.find_element_by_css_selector("a.btn.action.prefill-hs-done").click()

0 个答案:

没有答案