在我付款时的订单页面中,我会在付款清单页面中列出已创建的付款。创建的付款将始终列在表格的第一行。我想知道如何获取文本“这是项目: “也可以点击它。每笔付款都有自己的id连接,即以下是剪辑表格:
<div id="PAYMENT-CONTAINER" style="clear:both">
<div class="list-widget" id="PAYMENT-LIST">
<ul style="visibility: visible;" class="table">
<li id="393118">
<div class="no-expand col0" style="text-align: center; width: 31px;"><input type="checkbox" class="rowSelect" value="393118"></div>
<div class="no-expand col1" style="text-align: center; width: 57px;">
<span class="tag untagged">•••</span>
</div>
<div class="col2" style="text-align: center; width: 155px;">
07/28/2015
</div>
<div class="col3" style="width: 401px;">
5280 FAST PITCH
</div>
<div class="col4" style="width: 344px;">
This is Project:
</div>
<div class="col5" style="text-align: right; width: 213px;">
$25.00
</div>
<div class="col6" style="width: 188px;">
Stacey Smith
</div>
<div class="col7" style="width: 178px;">
In Process
</div>
</li>
<li id="393119">
<div class="no-expand col0" style="text-align: center; width: 31px;"><input type="checkbox" class="rowSelect" value="393119"></div>
<div class="no-expand col1" style="text-align: center; width: 57px;">
<span class="tag untagged">•••</span>
</div>
<div class="col2" style="text-align: center; width: 155px;">
07/28/2015
</div>
<div class="col3" style="width: 401px;">
5280 FAST PITCH
</div>
<div class="col4" style="width: 344px;">
Donations are for good cause
</div>
<div class="col5" style="text-align: right; width: 213px;">
$26.00
</div>
<div class="col6" style="width: 188px;">
Stacey Smith
</div>
<div class="col7" style="width: 178px;">
In Process
</div>
</li>
答案 0 :(得分:0)
你的案例的Xpath选择器是:// div [contains(text(),'This is Project:')] 。例如,如果webdriver的实例被称为“driver”,那么代码应为:
driver.findElement(By.xpath("//div[contains(text(), 'This is Project:')]")).click();
答案 1 :(得分:0)
如果您的所需文本“This is Project:”始终显示在第一行,那么您可以在xpath下面尝试: -
//li[1]/div[@class='col4']
//获取文字: - driver.findElement(By.xpath( “//利[1] /格[@类= 'COL4']”))的getText();
//点击它: - driver.findElement(By.xpath( “//利[1] /格[@类= 'COL4']”))点击();
答案 2 :(得分:0)
您可以使用以下xpath获取文本WebElement:
angular.module('mainApp')
.controller('reviewsCtrl', ['$scope', function($scope) {
$scope.loadReviews = function(subject_id) {
gridFactory.getReviews(subject_id)
.then(function(result) {
scope.reviews = result.data;
});
}
});
或
//div[@class='col4']
您可以使用任何一个xpath来查找网页元素。
这样的事情:
//div[contains(text(),'This is project');