Extend test object methods and properties - code samples (.NET SDK)
Use an OpenText Functional Testing property in a description
Use the acc_name property to identify a specific web element.
[TestMethod]
public void TestWeb()
{
// Create the browser
IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
browser.Navigate("https://www.advantageonlineshopping.com/#/");
browser.Sync();
// Create the object property dictionary that will hold the OpenText Functional Testing property name and value, and initialize it
IDictionary<string, object> objProp = new Dictionary<string, object>
{
{ "acc_name", "TabletsCategory" }
};
// Describe the web element using the object property (It can also be used together with other properties.)
var tabletsCategoryWebElement = browser.Describe<IWebElement>(new WebElementDescription
{
ObjectProperties = objProp
});
// Do operation on web Element
tabletsCategoryWebElement.Highlight();
browser.Close();
}
Call an OpenText Functional Testing test object method or property
Call a method that returns no value and does not require arguments:
[TestMethod]
public void FTClick()
{
IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
browser.Navigate("https://advantageonlinebanking.com/");
browser.Sync();
var registrationButton = browser.Describe<IButton>(new ButtonDescription
{
TagName = @"BUTTON",
Name = @"Registration",
ButtonType = @"button"
});
registrationButton.CallFTMethod("Click");
}
Call a method that returns no value but requires arguments:
[TestMethod]
public void FTClickPoint()
{
IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
browser.Navigate("https://advantageonlinebanking.com/");
browser.Sync();
var registrationButton = browser.Describe<IButton>(new ButtonDescription
{
TagName = @"BUTTON",
Name = @"Registration",
ButtonType = @"button"
});
registrationButton.CallFTMethod("Click", 10,10,1);
}
Call a method that returns a value and does not require arguments:
[TestMethod]
public void FTExists()
{
IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
browser.Navigate("https://advantageonlinebanking.com/");
browser.Sync();
var registrationButton = browser.Describe<IButton>(new ButtonDescription
{
TagName = @"BUTTON",
Name = @"Registration",
ButtonType = @"button"
});
bool result = registrationButton.CallFTMethod<bool>("Exist");
Assert.IsTrue(result);
}
Call a method that returns a value and requires arguments:
[TestMethod]
public void FTExistsWTimeout()
{
IBrowser browser = BrowserFactory.Launch(BrowserType.Chrome);
browser.Navigate("https://advantageonlinebanking.com/");
browser.Sync();
var registrationButton = browser.Describe<IButton>(new ButtonDescription
{
TagName = @"BUTTON",
Name = @"Registration",
ButtonType = @"button"
});
bool result = registrationButton.CallFTMethod<bool>("Exist", 10);
Assert.IsTrue(result);
}