大家好我正在尝试制作一个上传文件的机器人,并读取上传栏的百分比。我已经有了读取百分比的代码,但是当我实际点击上传按钮时,它会一直挂起,直到完全上传为止。
driver.find_element_by_css_selector("Upload").click()
while 1:
driver.find_element_by_css_selector("Percentage").text
我也尝试过使用线程(这是我第一次使用线程),它似乎只是调用函数一样。
def get_percent():
while 1:
testy = driver.find_element_by_css_selector("Percentage").text
print testy
def start_upload():
driver.find_element_by_css_selector("Upload").click()
w = threading.Thread(name='get_percent', target=get_percent())
e = threading.Thread(name='start_upload', target=start_upload())
e.start() #It will hang on upload
w.start()
#if i do it like this instead it will hang in my get_percent function
#w.start()
#e.start()
我如何解决这个问题?请帮忙