2017-05-16 126 views
-4

NoSuchElementException異常中的硒的webdriver在python

div class="row-fluid"> 
 
<div id="sfx" class="span12"> 
 
<ui-view> 
 
<div class="row-fluid fa-rep-nav"> 
 
<div id="test"></div> 
 
<div class="row-fluid"> 
 
<div id="sfx" class="span12"> 
 
<ui-view> 
 
<div class="row-fluid"> 
 
<div class="span12"> 
 
<div class="ledger-btn-block clearfix"> 
 
<form class="ng-pristine ng-valid" name="reportGenForm"> 
 
<span class="input-append ledger-date-block fa-block-pull-left"> 
 
<label class="ledger-label">Select‌·Report:‌·&nbsp;</label> 
 
<select class="select_report_type ng-pristine ng-untouched ng-valid" ng-model="selectedReport" ng-options="str.name for str in reportType"> 
 
<label class="ledger-label">&nbsp;‌·Date‌·Range:‌·&nbsp;</label> 
 
<input class="date-picker report-date-input ng-pristine ng-untouched ng-valid" date-range-picker="" readonly="" ng-model="sfxReportModel.date" options="selectedReport.opts" min="selectedReport.opts.minDate" max="selectedReport.opts.maxDate" type="text"> 
 
<i class="icon-calendar add-on no-border-radius"></i> 
 
</span>

我已經使用定位其在這裏是適用的元件的所有的方法。我也用time.sleep()函數,以便在其上我定位元素的頁面可以找到以前成功加載,但即使如此,也位置不appearing.Here是HTML代碼中的照片。突出顯示的是我想要找到的人。 我用像find_element_by_xpath和find_by_class_name方法從哪裏獲得使用Firebug,但得到了同樣的錯誤enter image description here的XPath。我需要幫助找到「選擇」標籤。

+0

而不是*描述*你已經嘗試後您的實際代碼。另外,將html作爲文本發佈,而不是圖像。 – Guy

+0

現在添加了html版本的代碼。 – Blasteraj

+0

你可以添加一些代碼,你已經嘗試了什麼,你想找到的東西。你給出的解釋並不清楚 – NarendraR

回答

0

據我瞭解,你要選擇的下拉列表。使用下面的代碼在python選擇下拉值

from selenium.webdriver.support.ui import Select 
select = Select(driver.find_element_by_xpath("//select[@class='select_report_type ng-pristine ng-untouched ng-valid']")) 
select.select_by_index(1) 
// OR 
select.select_by_visible_text("text") 
// OR 
select.select_by_value(value) 

讓我知道如果仍然面臨着同樣的問題或任何其他的東西

相關問題