Extend test object methods and properties - code samples (JavaScript SDK)
Use an OpenText Functional Testing property in a description
Use the acc_name property to identify a specific web element.
it("Use custom property on web", function(done) {
// Create the browser
Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
browser.navigate("https://www.advantageonlineshopping.com/#/");
// Create the object property map that will hold the OpenText Functional Testing property name and value and initialize it.
var props = {"acc_name": "TabletsCategory"}
// Describe the web element using the object property (It can also be used together with other properties.)
var tabletsCategoryLink = browser.$(Web.Link({
objectProperties: props
}));
// Do operation on web Element
tabletsCategoryLink.highlight();
browser.close();
});
whenDone(done);
});
Call an OpenText Functional Testing test object method or propert
Call a method that returns no value and does not require arguments:
it("FTClick", function(done) {
Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
browser.navigate("https://advantageonlinebanking.com/");
browser.sync();
var registrationButton = browser.$(Web.Button({
tagName: "BUTTON",
name: "Registration",
buttonType: "button"
}));
registrationButton.callFTMethod("Click");
browser.close();
});
whenDone(done);
});
Call a method that returns no value but requires arguments:
it("FTClickPoint", function(done) {
Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
browser.navigate("https://advantageonlinebanking.com/");
browser.sync();
var registrationButton = browser.$(Web.Button({
tagName: "BUTTON",
name: "Registration",
buttonType: "button"
}));
registrationButton.callFTMethod("Click", 10, 10, 0);
browser.close();
});
whenDone(done);
});
Call a method that returns a value and does not require arguments:
it("FTExist", function(done) {
Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
browser.navigate("https://advantageonlinebanking.com/");
browser.sync();
var registrationButton = browser.$(Web.Button({
tagName: "BUTTON",
name: "Registration",
buttonType: "button"
}));
registrationButton.callFTMethod("Exist").then((result) => {
expect(result).toBe(true)
});
browser.close();
});
whenDone(done);
});
Call a method that returns a value and requires arguments:
it("FTExistWTimeout", function(done) {
Web.Browser.launch(Web.BrowserType.Chrome).then(function (browser) {
browser.navigate("https://advantageonlinebanking.com/");
browser.sync();
var registrationButton = browser.$(Web.Button({
tagName: "BUTTON",
name: "Registration",
buttonType: "button"
}));
registrationButton.callFTMethod("Exist", 20).then((result) => {
expect(result).toBe(true)
});
browser.close();
});
whenDone(done);
});
See also: