我有这段代码:
// Change frame
btnName.frame = CGRectMake(screenWidth/3, screenHeight/2, 100, 100)
// Change center of button
btnName.center = CGPoint(x: screenHeight/2, y: screenWidth/2)
这是一种按属性“名称”搜索的简单方法。但它不是通用的,因为它带有标记 by.addLocator('Name',
function(spanText, opt_parentElement) {
var using = opt_parentElement || document;
var td = using.querySelectorAll('td');
return Array.prototype.filter.call(td, function(teg) {
return teg.getAttribute("Name") === spanText;
});
});
的搜索元素。我怎样才能使它独立于标记?
答案 0 :(得分:4)
您可以向定位器添加任意数量的参数,因此在CREATE PROCEDURE get_output
@Date DATE
,@ID INT
,@Output INT OUTPUT -- 1 true , 0 false
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Count INT;
SELECT @Count = COUNT(*)
FROM TableName
WHERE CAST(DATEADD(WEEK, DATEDIFF(WEEK, 0, @Date), 0) AS DATE)
= CAST(DATEADD(WEEK, DATEDIFF(WEEK, 0, [Date]), 0) AS DATE)
AND ID = @ID
GROUP BY CAST(DATEADD(WEEK, DATEDIFF(WEEK, 0, [Date]), 0) AS DATE)
IF (@Count < 2)
SET @Output = 1;
ELSE
SET @Output = 0;
END
之后您可以包含spanText
。您可以更进一步,不要将自己置于使用仅标记参数的范围内,而是使用tagName
支持的任何选择器:
querySelectorAll()
用法:
by.addLocator('Name', function (spanText, selector, opt_parentElement) {
var using = opt_parentElement || document;
var els = using.querySelectorAll(selector);
return Array.prototype.filter.call(els, function (el) {
return el.getAttribute('Name') === spanText;
});
});