我正在用Selenium A函数测试我的Django项目。
经过一些处理后,我有一个按钮要点击,它会重定向到另一个页面。
我用来测试它:
@classmethod
def wait_until(cls, findhow, findwhere):
WebDriverWait(cls.selenium, 10).until(EC.presence_of_element_located((findhow,findwhere)))
所以,我(Selenium)单击按钮,它重定向到一个页面,在这个页面上,有一个
text_table
. 此表是我正在检查以检测重定向的元素。
self.wait_until(By.ID, 'text_table')
但我马上(毫不停顿地)得到了
500 server error
,带有回溯:
Traceback (most recent call last):
File "/mnt/backup/BACKUP_Aubrey/workspace/LingL/functional_tests/selenium_text_detail.py", line 56, in test_create_a_new_text
self.wait_until(By.ID, 'text_table')
File "/mnt/backup/BACKUP_Aubrey/workspace/LingL/functional_tests/selenium_base.py", line 53, in wait_until
EC.presence_of_element_located((findhow,findwhere))
File "/home/campagne/backup_ln/.Envs/LingL/lib/python3.7/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
(消息部分为空)
知道吗?
浏览器似乎没有考虑等待时间(10、20或30秒…)和立即重定向。我猜505错误是由于这样一个事实:由于重定向是即时的,不允许在单击事件之后进行我编码的处理(它处理由get发送的一些值)