Assert.AreEqual() not recognising dynamically updated values
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?
Thread.sleep (5000) - This is not a best practice because your tests will run slowly. You should to try waitForElementPresent better
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.
精彩评论