你的问题
元素的可见性是否是部分链接的低于标准选择
文字?
不,绝对不。
查看visibility_of_element_located 方法下面的内容:-
""" An expectation for checking that an element is present on the DOM of a
page and visible. Visibility means that the element is not only displayed
but also has a height and width that is greater than 0.
locator - used to find the element
returns the WebElement once it is located and visible
"""
class visibility_of_element_located(object):
def __init__(self, locator):
self.locator = locator
def __call__(self, driver):
try:
return _element_if_visible(_find_element(driver, self.locator))
except StaleElementReferenceException:
return False
所以基本上它会调用,
_element_if_visible
这就是我们所拥有的
def _element_if_visible(element, visibility=True):
return element if element.is_displayed() == visibility else False
所以,对您的问题的直接回答是否定的。但这取决于您如何定义 EC,在您的情况下,您确定这是唯一的 link_text 还是 partial_link_text,
您是否尝试将其更改为 css 或 xpath 并进行如下验证?
//*[contains(text(),'Hello')]
在代码中:
msg_receive_1 = WebDriverWait(driver1, 15).until(
EC.visibility_of_element_located((By.XPATH, "//*[contains(text(),'Hello')]"))
)
作为 xpath ?