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:· </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"> ·Date·Range:· </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()函数,以便我在找到元素的页面可以在找到之前成功加载,但即使这样,位置也不会出现。这是html代码的图片。突出显示的是我想要找到的那个。 我使用了find_element_by_xpath和find_by_class_name之类的方法,其中我使用Firebug获取xpath但得到相同的错误enter image description here。我需要帮助找到“选择”标签。
答案 0 :(得分: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)
如果仍然面临同样的问题或任何进一步的事情,请告诉我