Hi,
Thanks for your replies .I have used following approach to find the position of two elements relative to each other.
I have added the following functions in user-extentions.js
Selenium.prototype.assertElementAbove = function(locator1, locator2) {
var element1 = this.page().findElement(locator1);
var element2 = this.page().findElement(locator2);
// Get Y coordinates of elements
var Y1 = findPosY(element1);
var Y2 = findPosY(element2);
if(parseFloat(Y1) < parseFloat(Y2))
{
Assert.matches('1', '1');
// here I wanted a command which tells selenium that the test is correct and as I don't know that I matched 1 with 1
}
else
{
Assert.matches('First element is below or at the same place as second ','1','2');
// here I wanted a command which tells selenium that the test is failed and as I don't know that I matched 1 with 2
}
};
function findPosY(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
and used following code in my test script
<!-- to find if "Print my bill" is above "Bill messages" link -->
<tr>
<td>verifyElementAbove</td>
<td>link=Print my bill</td>
<td>link=Bill messages</td>
</tr>
Its running fine and there are no issues with it.
BUT as you see I have used Assert.matches('1', '1'); to make sure that this test pass when if condition is satisfied and Assert.matches('First element is below or at the same place as second ','1','2'); where it fails. This is just a work around as I don't know what command is there to tell selenium that the test is correct / incorrect
Does anyone has idea if there is some command like assertGreater etc. or any other better way to do that.
Regards,
Rahul Chaturvedi
_______________________________________________ Selenium-users mailing list Selenium-users@lists.public.thoughtworks.org http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users