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

issue - #3655 #4289

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
13 changes: 11 additions & 2 deletions lib/api/protocol/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const ProtocolAction = require('./_base-action.js');
* @api protocol.frames
*/
const findElement = function(selector) {

return new Promise((resolve, reject) => {
this.api.findElement({selector, suppressNotFoundErrors: true}, function(res) {
if (res.status === -1 && res.error) {
Expand All @@ -52,7 +51,17 @@ module.exports = class Session extends ProtocolAction {
return this.transportActions.switchToFrame(callback);
}

if (typeof frameId == 'string') {
// Check if frameId is a page object element by checking if it starts with "@"
if (typeof frameId === 'string' && frameId.startsWith('@')) {
// Resolve the page object selector to an actual CSS selector
frameId = await this.api.resolveElement(frameId)
.catch(err => {
throw new Error(`Unable to resolve page object selector ${frameId}.`);
});
}

// Proceed with finding the frame element using the resolved selector
if (typeof frameId === 'string') {
frameId = await findElement.call(this, frameId)
.catch(err => {
return findElement.call(this, `*[name="${frameId}"]`);
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7950,4 +7950,4 @@ declare global {
const ensure: Ensure;
const expect: Expect;
const locateWith: typeof seleniumLocateWith;
}
}