Assert.AreEqual() 无法识别动态更新的值

发布于 2024-09-17 20:14:40 字数 382 浏览 3 评论 0原文

我有一个应用程序,您可以在其中选择地图的一个区域,然后我们的 产品价格表变化(取决于地图区域、大小等)

所以在我的测试中,我使用 runScript() 来调用底层的 JS 方法 地图,价格更新,我对价格做了简单的检查 设置ala Assert.AreEqual(priceValue, selenium.GetText(priceElement));

我使用 RC 和 C# 来运行测试。

问题是当我不通过调试运行测试时 开启价格检查失败。

我很确定问题是在价格之前进行了检查 但是如果我放入 selenium.WaitForPageToLoad() 则更新 无论超时的值是什么。

鉴于我调用的脚本选择地图上的区域并更新 价格加上我可以在屏幕上看到它为什么我不能测试?

I have an application in which you select an area of a map and our
product price list changes (dependant of map area, size etc.)

So in my test, I use runScript() to call the JS method underlying the
map, the prices update and I do a simple check on the price that is
set ala Assert.AreEqual(priceValue, selenium.GetText(priceElement));

I use RC and C# to run tests.

The problem is that when I dont run the test with my debugging
switched on the price check fails.

I'm pretty sure the problem is the check is run before the price is
updated however if I put in a selenium.WaitForPageToLoad() at
whatever value it times out.

Given that the script I call selects the area on the map and updates
the price plus I can see it on the screen why cant my test?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牵你的手,一向走下去 2024-09-24 20:14:40

Thread.sleep (5000) - 这不是最佳实践,因为您的测试将运行缓慢。
你应该更好地尝试 waitForElementPresent

Thread.sleep (5000) - This is not a best practice because your tests will run slowly.
You should to try waitForElementPresent better

永言不败 2024-09-24 20:14:40

确实是一个非常简单的答案。

由于脚本未触发页面加载,WaitForPageToLoad 超时。

因此,使用 thread.Sleep(5000) 可以使元素有机会刷新,然后执行 Assert 即可使其正常工作。

Quite a simple answer really.

WaitForPageToLoad times out as the script doesnt trigger a page load.

So using thread.Sleep(5000) gives the element a chance to refresh then doing the Assert has got it working.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文