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

Fixing the bug in the frame() command #4259

Open
wants to merge 1 commit into
base: main
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
40 changes: 24 additions & 16 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
const path = require('path');
const path = require("path");
const Utils = require("../util/utils.js");
const exportedCommands = [
'element-commands/findElement.js',
'element-commands/findElements.js',
'element-commands/element.js',
'element-commands/elements.js',
'element-commands/elementIdElement.js',
'element-commands/elementIdElements.js',
'element-commands/waitForElementPresent.js',
'element-commands/waitForElementNotPresent.js',
'element-commands/waitForElementVisible.js',
'element-commands/waitForElementNotVisible.js',
'protocol/quit.js'
"element-commands/findElement.js",
"element-commands/findElements.js",
"element-commands/element.js",
"element-commands/elements.js",
"element-commands/elementIdElement.js",
"element-commands/elementIdElements.js",
"element-commands/waitForElementPresent.js",
"element-commands/waitForElementNotPresent.js",
"element-commands/waitForElementVisible.js",
"element-commands/waitForElementNotVisible.js",
"protocol/quit.js",
"element-commands/frame.js",
];

const basePath = '../lib/api';
const basePath = "../lib/api";
const Commands = {};
const props = exportedCommands.reduce((prev, fileName) => {
const commandName = fileName.substring(fileName.lastIndexOf('/') + 1).replace('.js', '');
const commandName = fileName
.substring(fileName.lastIndexOf("/") + 1)
.replace(".js", "");
prev[commandName] = {
configurable: true,
get: function() {
get: function () {
return require(path.join(basePath, fileName));
}
},
};

return prev;
}, {});

Object.defineProperties(Commands, props);

Utils.isPageObject = function (selector) {
return selector && typeof selector === "object" && selector.selector;
};

module.exports = Commands;
8 changes: 8 additions & 0 deletions lib/api/element-commands/frame.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = function frame(selector) {
const Utils = require("../util/utils.js");

return this.executeProtocolAction({
commandName: "frame",
args: [Utils.isPageObject(selector) ? selector.selector : selector],
});
};
10 changes: 3 additions & 7 deletions test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"skipLibCheck": true
/* Skip type checking all .d.ts files. */
},
"include": [
"."
],
"files": [
"./types/index.d.ts"
]
}
"include": ["."],
"files": ["./types/index.d.ts"]
}