Yes, you can. Using Google.com as an example, the code below is going to click the ''Google Search'' button using the ''I'm Feeling Lucky'' button VRI object.
First you need to create test object for your VRI object, then create a test object based on it's visual relation to your VRI object.
(Please note this will only work on the Google.com page if Instant Predictions are turned OFF in Search Settings on Google, otherwise as soon as data is entered into the search field, the buttons will disappear)
[TestInitialize]
public void TestInitialize()
{
//Create the browser object
IBrowser browser = BrowserFactory.Launch(BrowserType.Firefox);
browser.Navigate(''http://www.google.com'');
//Describe known objects
var luckyButton = browser.Describe(new ButtonDescription
{
ButtonType = @''submit'',
TagName = @''INPUT'',
Name = @''I'm Feeling Lucky''
});
var searchField = browser.Describe(new EditFieldDescription
{
Type = @''text'',
TagName = @''INPUT'',
Name = @''q''
});
//Set up the VRI
var searchButton = browser.Describe(
new ButtonDescription
{
ButtonType = ''Submit'',
Vri =
{
new VisualRelation
{
TestObject = luckyButton,
HorizontalRelation = HorizontalVisualRelation.RightAndInline,
}
}
});
//Enter Data in the Search Field
searchField.SetValue(''eyeontesting'');
//Click the Search button using VRI
searchButton.Click();
}
Here's a link with more info on how to use VRI: [http://leanft-help.saas.hp.com/en/12.50/HelpCenter/Content/HowTo/VRI.htm][1]
As noted on that page, you can also create VRI definitions in the Application Model Editor. For more info about the Application Model Editor, check out this post: [http://eyeontesting.com/questions/9738/how-to-quickly-add-aut-objects-to-leanft.html][2]
[1]: http://leanft-help.saas.hp.com/en/12.50/HelpCenter/Content/HowTo/VRI.htm
[2]: http://eyeontesting.com/questions/9738/how-to-quickly-add-aut-objects-to-leanft.html