3
我已经作出使用使用yadda库硒webdriver的功能性测试。问题在于,在我的不同环境中,相同的测试套件工作不同。例如:策略在JavaScript测试硒的webdriver在不同的环境
在测试中,它的基础上的环境,我进入是不同的结果。
本地本地主机:5000
Open my search site
․ when i go to my site: 2169ms
․ when i write a text on the search input: 21ms
․ when i click the search button: 130ms
․ then i get the results page.": 46ms
分期mystaging.domain.com
Open my search site:
StaleElementReferenceError: {"errorMessage":"Element is no longer attached to the DOM","request":{"headers":{"Accept":"application/json; charset=utf-8","Connection":"close","Content-Length":"2"
生产www.domain.com
Open my search site
․ when i go to my site: 2169ms
․ when i write a text on the search input: 21ms
․ when i click the search button: 130ms
․ then i get the results page.": 46ms
此时,只有分期测试是失败的,但在其他情况下,当互联网连接它的速度慢,测试生产失败,但传中分期。 的主要问题是,浏览器不具备的DOM准备好了测试,他们没有找到测试所需的元素。
我对试图解决这个问题的办法,这是等待出现我的网页的根元素是这样的:
return driver.wait(() => driver.isElementPresent(By.css(".my__homepage")), 50000);
但这是不够的,我的,因为测试套件仍然不能随意。所以,我的问题是:
这可能是在不同环境下运行的最佳方法,测试套件处理浏览器上未准备好的元素?
这似乎是你的DOM元素没有准备好一个问题。在访问任何元素之前,您应该对它们进行隐式等待。因此,如果您的响应时间从环境到环境的增加/减少,它不会中断测试。 –
感谢您的意见。我试图设定一个等待,但这不行。你知道是否存在一种方法可以100%确保我的测试等待整个HTML文档的加载,比如“准备就绪”事件或类似的事情? –
我可以给你举一些例子。您是否在使用C#或Java(或其他)Selenium? –