Unable to click an image using its Alt property

Jul 3, 2012 at 5:40 AM
Edited Jul 3, 2012 at 5:58 AM

Hi All,

 

I am unable to click an image using cuite. If i add an image to object repository and tried clicking on it. none of the other code is working.

 

 

Objejt repository has

public CUITe_HtmlImage ImgSignin = new CUITe_HtmlImage("alt=Sign-In");  

 

and i am trying to do 

 

CUITe_BrowserWindow.Launch("http://newtours.demoaut.com/mercurywelcome.php");            WelcomeMercuryTours PgLogin = CUITe_BrowserWindow.GetBrowserWindow();                                    PgLogin.txtuserName.SetText("deepakguna");            PgLogin.txtpassword.SetText("sarala1983");

PgLogin.ImgSignin.Click();


It says,
Search Pattern Key not supported -> 'Alt' in 'Alt=Sign-In'.
Am i missing something? 
Thanks in Advance,
-Deepak


Coordinator
Jul 3, 2012 at 8:45 PM

Hi Deepak,

The code the Visual Studio Coded UI Test Recorder generates includes the following search criteria for the "Sign-In" button:

this.mUILoginButton = new HtmlInputButton(this);
#region Search Criteria
this.mUILoginButton.SearchProperties[HtmlButton.PropertyNames.Name] = "login";
this.mUILoginButton.SearchProperties[HtmlButton.PropertyNames.DisplayText] = "Login";
this.mUILoginButton.FilterProperties[HtmlButton.PropertyNames.Type] = "image";
this.mUILoginButton.FilterProperties["Src"] = "http://newtours.demoaut.com/images/btn_signin.gif";
this.mUILoginButton.FilterProperties[HtmlButton.PropertyNames.ControlDefinition] = "border=0 name=login alt=Sign-In value=Lo";
#endregion

When I used the following definition, it worked without issues:

public CUITe_HtmlInputButton ImgSignin = new CUITe_HtmlInputButton("Name=login");

Note that the CUITe_HtmlImage class wraps an <image /> element whereas a CUITe_HtmlInputButton wraps an <input /> element and that is why your code failed.