我有一个应用程序,您可以在其中选择地图的一个区域,然后我们的
产品价格表变化(取决于地图区域、大小等)
所以在我的测试中,我使用 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?
发布评论
评论(2)
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
确实是一个非常简单的答案。
由于脚本未触发页面加载,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.