繁体   English   中英

如何直接使用pyhon-硒预期条件函数?

[英]How to use the pyhon-selenium expected condition functions directly?

对于python-selenium实现,您具有通常在WebDriverWait构造中使用的预期条件

element = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.ID, "myDynamicElement"))

我想直接使用此条件,而不需要WebDriverWait 但是做一个简单的

element = EC.presence_of_element_located((By.ID, "myDynamicElement"))

似乎不起作用。 那么怎么做/使用它呢?

然后,您可能想构建一个自定义方法来运行代码块

def try_bool(attempts = 10, duration = 0.2, interest = True)
  count = 0
  item_of_interest = null
  while item_of_interest == interest || count == attempts
    item_of_interest = interest
    time.sleep(duration)
    count += 1

element = driver.find_element_by_id('locator')
try_bool(10,1,element.is_displayed())

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM