Problem in using SearchCriteria.ByAutomationId(id)

Oct 19, 2010 at 10:13 AM

Hi all,

  I am trying to recognize a window with the following line of code,

 

Window win = App.Get<Window>(SearchCriteria.ByAutomationId("id"));

but it's throwing an error as "White.Core.Application" does not contain a definition for 'Get' and no extension method 'Get' accepting a first arguement White.Core.Application could not be found. Could any one please tell me if i'm missing any reference to any dll files ? I'm confused about which i'm missing.

 

Thanks in Advance.

Oct 19, 2010 at 10:19 AM

thats right, this way is not possible

 

Window window = App.GetWindows().Where(p=>p.AutomationElement.Current.AutomationID =="id").First();

 

Throndorin

Oct 19, 2010 at 10:29 AM

Thank you Throndorin,

 

  But the same error for "Current" in the line you have provided.

Window window = App.GetWindows().Where(p=>p.AutomationElement.Current.AutomationID =="id").First();

Not able to find System.Windows.Automation.AutomationElement

I'm looking for that dll in my machine but no success.

Thanks in advance.

 

 

Oct 19, 2010 at 10:45 AM

Thank you I'm able to reference the file.

Oct 19, 2010 at 10:49 AM

 

Hi

 

in Visual Studio look for UIAutomationClient, UIAutomationClientsideProviders, UIAutomationProvider and UIAutomationTypes as References

 

Throndorin

Oct 19, 2010 at 11:04 AM
Edited Oct 19, 2010 at 11:05 AM

Ok I ma

de reference to all dll's mentioned but It still has some problems. I'm not able to understand what the P is in your code ? It says p is does not exist in this context.

 

Thanks in advance

Oct 19, 2010 at 11:08 AM

 

Hi

 

this is a Linq expression (using System.Linq;)

is the same as I write:

 

 

foreach(Window window in windows)
{
  if(window.AutomationElement.Current.AutomationID == id)
  {
    return window;
  }
}

Throndorin