Strange Page object behaviour in IE 11 compared to Firefox and IE 8 (JScript test)
Hi,
I am creating a simple 'hello world'-ish test so that we can try to run it on our new continous integration environment and start building our test suite from there. And we've encountered some problems.
Google Chrome 38 is not supported by TestComplete yet. It will launch Chrome, but then fails to find it and give an error. We have not been able to find and install an older version of Chrome, since all download links we could find point to the generic installer that automatically downloads and installs the latest version. We could not find a patch here either: http://support.smartbear.com/downloads/testcomplete/chrome-patches/.
Firefox simply gave an error that it can not run in a non-interactive session. It is a problem we can not fix right now, and we weren't sure if it also happens on other browsers, so we tried IE.
I wrote the test on my machine using IE 8, but the CI server uses IE 10. This leads to similar behaviour as Chrome, where it will launch IE 10, but then lose track of it.
I have since then gotten a new pc which has IE 11 installed. So I rewrote the test to use IE 11, hoping it could work for IE 10 as well, but now the test fails for me with some strange behaviour.
First of all I have 2 helper functions:
function FindObjectByXpath(page, xpath){
/*
Attempts to find a child object from a Page object by xpath. It attempts to find an object once per second
for 3 seconds to deal better with slow or async loading pages. It will return the object if found, or log an error if not.
Arguments:
page - Page object
xpath - a String xpath expression pointing to a unique web element
Return:
Object
*/
var retries = 3;
var obj = page.FindChildByXPath(xpath);
while (obj == null && retries != 0){
delay(1000);
retries--;
obj = page.FindChildByXPath(xpath);
}
if (obj == null){
Log.Error("No object found for xpath: " + xpath);
} else {
return obj;
}
}
function ClickItemByXpath(page, xpath){
/*
Attempts to find a child object from a Page object by xpath, and simulate a left mouse click on that object.
It also has a delay of 1 second to better deal with slow or async loading pages.
Arguments:
page - Page object
xpath - a String xpath expression pointing to a unique web element
*/
var obj = FindObjectByXpath(page, xpath)
obj.click();
Delay(1000);
}
The actual test is:
function hello_world(){
1 var url = "tweakers.net";
2 var browser = TestedApps.Firefox.run();
3 var page = browser.toUrl(url);
4
5 ClickItemByXpath(page, "//a[@href='http://tweakers.net/nieuws/']");
6 Delay(1000);
7 var obj = FindObjectByXpath(page, "//input[@name='keyword']");
8 CheckProperty(obj, "outerHTML", 6, "Zoek naar nieuws");
}
To test it in different browsers, I would simply change the browser in line 2: TestedApps.<browser>.run() to whatever browser I defined in TestedApps. This worked for switching between Firefox 33.1 and IE 8. But it doesn't for IE 11.
What I've noticed is: When you run the test in FF or IE 8, line 3 will obtain a Page object with URL property: "http://tweakers.net" (screenshot 1). When you click a link in line 5, it will update the Page object to the new URL "http://tweakers.net/nieuws/ (screenshot 2). However, when I do the same actions on IE 11, it does not update the Page object (screenshot 3 and 4). So my tests checks the wrong object property value and fails.
Is this intended behaviour?
Regards,
Kevin