AirtestProject / AirtestProject/Poco

能否新增一个获取某个元素在其兄弟节点中的索引值,或者可以直接获取该元素的上一个节点和下一个节点

Đang mở
#585 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
2k
Fork
341
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

现在我们有一个场景是
1234567 | connect
1234568 | connect
1234569 | connect
1234566 | connect

而元素列表如下: "12345.." 和 “connect” 全都在同一级,没有对应的关系
![image](https://github.com/AirtestProject/Poco/assets/44250052/921fda59-588f-40b1-90dd-3fed7be7b580)

左侧的数字是随时变动的,我无法直接通过左侧数字定位到右侧的connect 的按钮

我自己写了一个解决的方案,但是速度不尽如人意,想来应该还是得从更底层去解决这个
def index(self):
"""
Returns the index of the element in the subset of the parent element

"""
start = time.time()
sub_query = build_query(None) # as placeholder
query = ('-', (self.query, sub_query))
obj = UIObjectProxy(self.poco)
obj.query = query
position = [x.get_position() for x in obj]
return position.index(self.get_position())

def last_sibling(self):
"""
Returns the sibling to the left of an element

"""
sub_query = build_query(None)
query = ('-', (self.query, sub_query))
obj = UIObjectProxy(self.poco)
obj.query = query
return obj[self.index() - 1]

def next_sibling(self):
"""
Returns the sibling to the right of an element

"""
sub_query = build_query(None)
query = ('-', (self.query, sub_query))
obj = UIObjectProxy(self.poco)
obj.query = query
return obj[self.index()+1]

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.