class DockerContainerDeployer(object):
self.browser = webdriver.Firefox()
def deploy(self)
# actions...
# wait until the docker container is deployed
# by checking a div that give us the status
while not self._is_visible("#cluster-status .deployed"):
# you can add an implicity wait to check it every 10s with
# self.browser.implicitly_wait(10)
pass
# docker container deployed
def _is_visible(self, locator, timeout = 2):
"""
Check if an element is visible
"""
try:
ui.WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((By.CSS_SELECTOR, locator)))
return True
except TimeoutException:
return False
这取决于你在等什么。在
下面是一个使用
while
和_is_visible
函数等待元素出现在页面上的示例,以检查页面上是否存在该元素:您可以在因特网上找到关于python循环的文档。在
下面是一个示例:
好好读书!在
相关问题 更多 >
编程相关推荐