I am having some issues with the InputTag.Value property when the value is updated dynamically (via javascript)
I have knocked up an example of this using this html page and test code:
Code: Select all
<!DOCTYPE html>
<html>
<body>
<input id="textbox" type="text" />
<script>
window.setTimeout(enterText, 10000);
function enterText() {
document.getElementById('textbox').value = 'test';
}
</script>
</body>
</html>
Code: Select all
void ITestModule.Run()
{
//Open Chrome
Host.Local.OpenBrowser(Directory.GetCurrentDirectory() + "\\testpage.html", "iexplore", "", false, true);
//Uncomment this to make test pass
//Delay.Milliseconds(15000);
//Setup Elements
WebDocument dom = new WebDocument(Host.Local.FindSingle("/dom[@page='testpage.html']", Duration.Parse("5000")));
InputTag input = new InputTag(dom.FindSingle(".//input[#'textbox']"));
//Set up stopwatch for loop
Stopwatch sw = new Stopwatch();
sw.Start();
//Wait for input value to be "test"
//This should happen after 15 seconds
//Bomb out after 60 seconds using sw
do{
Report.Info(input.Value);
}while(input.Value != "test" && sw.ElapsedMilliseconds < 60000);
//End Test
if(input.Value == "test"){
Report.Success(input.Value);
}else{
Report.Failure(input.Value);
}
}
1. A page loads slightly slowly we wait for the text in a text box to be a certain value. If we check too quickly we forever get null
2. A hidden input box with a span controlling it (devs said this was a styling thing) when the span is clicked the inputbox should update to checked, but didn't.
Any workarounds?
Regards,
Mike