Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: vyper locator sample #150

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conf/profile.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ exports.config = {
],
locators: [
{name: './locators/jqueryLocator'},
{name: './locators/controlLocator'}
{name: './locators/controlLocator'},
{name: './locators/vyperLocator'}
],

plugins: [
Expand Down
39 changes: 39 additions & 0 deletions src/locators/vyperLocator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
var ControlLocator = require('./controlLocator');

/**
* Example of how to register a new locator that
* accepts an arbitrary JSON, translates it to an OPA5 declarative JSON object, and uses the internal logic of by.control to find a control
* @constructor
* @param {Config} config
* @param {Object} instanceConfig
* @param {Logger} logger
*/
function VyperLocator(config, instanceConfig, logger) {
this.config = config;
this.instanceConfig = instanceConfig;
this.logger = logger;
}

/**
* Register custom locator
* @param {ProtractorBy} by protractor By object on which to add the new locator
*/
VyperLocator.prototype.register = function (by) {
this.logger.debug('Registering custom locator');
by.ui5 = function (mMatchers) {
// mMatchers = {elementProperties:{metadata: "sap.m.Button"}}
// mOPA5Matchers = {controlType: "sap.m.Button"}
var mOPA5Matchers = {};
if (mMatchers.elementProperties && mMatchers.elementProperties.metadata) {
mOPA5Matchers.controlType = mMatchers.elementProperties.metadata;
}
var byControlLocator = new ControlLocator(this.logger);
// the new locator will find elements by the OPA5 control locator.
// if an element is not found, the selector will be logged as a stringified JSON
return byControlLocator.apply(mOPA5Matchers);
};
};

module.exports = function (config, instanceConfig, logger) {
return new VyperLocator(config, instanceConfig, logger);
};