我自己写了一个解决的方案,但是速度不尽如人意,想来应该还是得从更底层去解决这个
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]
现在我们有一个场景是 1234567 | connect 1234568 | connect 1234569 | connect 1234566 | connect
而元素列表如下: "12345.." 和 “connect” 全都在同一级,没有对应的关系
左侧的数字是随时变动的,我无法直接通过左侧数字定位到右侧的connect 的按钮
我自己写了一个解决的方案,但是速度不尽如人意,想来应该还是得从更底层去解决这个 def index(self): """ Returns the index of the element in the subset of the parent element