“Python tunggu sampai” Kode Jawaban

Python tunggu sampai

import time
def waitUntil(condition, output): #defines function
    wU = True
    while wU == True:
        if condition: #checks the condition
            output
            wU = False
        time.sleep(60) #waits 60s for preformance

waitUntil(Cookies >= 0, eatCookies()) #runs function (output MUST be another function)
Whoop de Doop

Python tunggu sampai

import contextlib
import selenium.webdriver as webdriver
import selenium.webdriver.support.ui as ui

with contextlib.closing(webdriver.Firefox()) as driver:
    driver.get('http://www.google.com')
    wait = ui.WebDriverWait(driver,10)
    # Do not call `implicitly_wait` if using `WebDriverWait`.
    #     It magnifies the timeout.
    # driver.implicitly_wait(10)  
    inputElement=driver.find_element_by_name('q')
    inputElement.send_keys('Cheese!')
    inputElement.submit()
    print(driver.title)

    wait.until(lambda driver: driver.title.lower().startswith('cheese!'))
    print(driver.title)

    # This raises
    #     selenium.common.exceptions.TimeoutException: Message: None
    #     after 10 seconds
    wait.until(lambda driver: driver.find_element_by_id('someId'))
    print(driver.title)
Bewildered Beaver

Jawaban yang mirip dengan “Python tunggu sampai”

Pertanyaan yang mirip dengan “Python tunggu sampai”

Lebih banyak jawaban terkait untuk “Python tunggu sampai” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya