【发布时间】:2020-09-17 08:13:07
【问题描述】:
我试图在每次更改时打印跨度的值。打印 span 的值非常简单:
popup = wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="spot"]')))
Print(popup.text)
这将打印当时的值,问题是该值将每 2 秒更改一次。我尝试使用:
# wait for the first popup to appear
popup = wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="spot"]')))
# print the text
print(popup.text)
# wait for the first popup to disappear
wait.until(EC.staleness_of(popup))
# wait for the second popup to appear
popup = wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="spot"]')))
# print the text
print(popup.text)
# wait for the second popup to disappear
wait.until(EC.staleness_of(popup))
Print(popup) 命令,它部分工作。它打印了 489 次相同的值,直到它改变并再次打印了另一个 489 次。我已经尝试过这段代码:
popup = wait.until(EC.text_to_be_present_in_element_value((By.XPATH, '//*[@id="spot"]')))
print(popup.text)
TypeError: __init__() missing 1 required positional argument: 'text_'
请帮助我需要添加什么或者我需要使用什么方法来获取更改的值。
求求你,请注意我没有尝试打印跨度的文本,我已经知道该怎么做,我想在每次更改时打印它
【问题讨论】: