2017-05-16 33 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) 

让我知道如果仍然面临着同样的问题或任何其他的东西

相关问题