Pergunta

I'm trying to use the Telerik Test Framework to automate some website testing.

To this end, I need to be able to analyze an ajaxified tooltip managed by a RadToolTIpManager which displays a user control containing a RadGrid. The site itself renders and responds as expected, but occasionally in testing the MouseHover() which I try to invoke to bring up the tooltip yields an Object reference not found for the image.

Here is example markup for the image I'm trying to hover over:

<img id="ctl00_ContentBody_CustomerSummary__TheImage" 
src="../images/Fire.png">

Below are the steps used by the test to initiate the automation:

private const int _sleepTimeout = 3000;
private MainPageObjectClass _HomePage;

OpenMainPage();

ActiveBrowser.WaitUntilReady();
ActiveBrowser.WaitForAjax(_sleepTimeout);

var theImage = _HomePage.MyToolTipImage;

The exception will occur in this method, which lives in a class where the page objects are defined and properties are used to get references to those object instances:

public void HoverOverTheImage()
{
    // Exception occurs below...
    MyToolTipImage.MouseHover();
}

Below is how I'm attempting to retrieve a reference to an instance of TheImage on the page (I'm traversing the DOM using the Get<HtmlImage> method with a wildcard search based on the image control's id, which again comes back as non-NULL every time):

/// <summary>
/// Image which upon MouseHover() should show the tooltip control.
/// </summary>
public HtmlImage MyToolTipImage
{
    get
    {
        return Get<HtmlImage>("id=~__TheImage", "tagname=img");
    }
}

I've tried adding the ActiveBrowser.WaitUntilReady() and ActiveBrowser.WaitForAjax(_sleepTimeout) methods between test steps, and tried increasing the timeouts, but in spite of this the test will occasionally fail due to a NULL reference to the image element.

What could be causing this automation to fail to find the image I need to MouseHover()?

UPDATE: According to a colleague of mine more familiar with the Telerik test framework, the MouseHover() method is more of a hardware-level means of hovering over a given element. The tests so frequently fail because I'm running the tests locally on my development machine, and of course the mouse is all over the place when the test is trying to run.

Foi útil?

Solução

Have you tried another way to retrieve reference to the image on the page? You could use the Find.Byxxx methods of the Telerik Testing Framework: http://docs.telerik.com/teststudio/user-guide/write-tests-in-code/intermediate-topics/element-identification/finding-page-elements.aspx . If the image indeed is successfully found on the page - for hovering the element you could use InvokeEvent method. The following code shows an example:

HtmlImage image = Find.ById<HtmlImage>("~TheImage");
Assert.IsNotNull(image);
image.InvokeEvent(ScriptEventType.OnMouseOver);

Usually the MouseHover method should make it work but it’s possible that the element is not visible in the browser window when executing the step.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top