1

Closed

whitespace in attributes are not preserved when CUITe looks for controls

description

I have a button that looks like this on the page...
 
<input name="ctl01" type="submit" class="btn" onclick="set_hit_submit_button()" value="   Search   " />
 
When I set up this button in the object repository, I created it like this...
    public CUITe_HtmlInputButton btnSearch = new CUITe_HtmlInputButton("Value=   Search   ");
Actually, the Object recorder created like this...
    public CUITe_HtmlInputButton btnSearch = new CUITe_HtmlInputButton("Name=ctl01;Name=ctl01;Value=   Search   ");
That could be another issue with the recorder
 
Anyways, on playback, I got the error about not finding the control because when searching, the whitespace after search was trimmed.
Test method BugTracker.CUITe.Tests.SearchTest.SearchUsingReportedByFieldOnly threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'Web'
ControlType: 'Button'
TagName: 'INPUT'
ValueAttribute: '   Search'
Failed to find any control that matched the search condition ControlType='Button' && ValueAttribute='   Search' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
 
 
The site I'm automating used whitespace to make the button bigger so I think this is a valid case where whitespace should be supported in the attributes of controls.
Closed Feb 14, 2013 at 7:27 AM by icnocop
Fixed in CUITe 1.0.6 Beta

comments

icnocop wrote May 17, 2012 at 7:39 AM

Thank you for reporting this issue.
As a work-around, you can use the following definition:
public CUITe_HtmlInputButton btnSearch = new CUITe_HtmlInputButton("Value= Search ;"); //notice the semicolon at the end

bzryan wrote May 17, 2012 at 5:52 PM

Using the workaround, the whitespace is perserved in the error message but the control still cannot be found.
Test method BugTracker.CUITe.Tests.SearchTest.SearchUsingReportedByFieldOnly threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName: 'Web'
ControlType: 'Button'
TagName: 'INPUT'
ValueAttribute: '   Search '
Failed to find any control that matched the search condition ControlType='Button' && ValueAttribute='   Search ' ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

If I delete the whitespace from the html and change the definition to the below, the button still cannot be found.
<input name="ctl01" type="submit" class="btn" onclick="set_hit_submit_button()" value="   Search" />

public CUITe_HtmlInputButton btnSearch = new CUITe_HtmlInputButton("Value= Search;")

But if I remove the ';' in the definition, the button will be found and is clickable by automation.
So it seems like the ';' in the definition is causing the button not to be found

icnocop wrote May 22, 2012 at 1:08 AM

Which version of CUITe are you using?

Thank you.

bzryan wrote May 25, 2012 at 5:20 PM

CUITE v1.05

icnocop wrote May 26, 2012 at 12:08 AM

I was not able to reproduce your issue.

Using the following definition worked without issue:

public CUITe_HtmlInputButton btnSearch = new CUITe_HtmlInputButton("Value= Search ;");

I am thinking this is a general issue where the playback cannot find any of your controls for some reason.

Did you set any playback settings to a custom value?

Is there more than one button with a value of " Search "?

Thank you.

icnocop wrote Jun 9, 2012 at 2:41 AM

Changeset #17145 has a unit test called HtmlInputButton_GetWithValueContainingWhitespace_Succeeds which validates the expected behavior.

icnocop wrote Aug 9, 2012 at 7:15 AM

This is now fixed with changeset 19095.
It will also be reflected in CUITe v1.6.