Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others


0 votes
in Technique[技术] by (71.8m points)

python - "Message: stale element reference: stale element not found" when trying to get the element using global method define in Javascript

This is the code on .ts file export class UploadController { readonly fileSelectorOverlayRoot = document.createElement('div'); readonly fileSelectorOverlayTarget = document.createElement('div');

// Marked public solely for the purpose of testing. Do not access directly. readonly 
fileSelectorOverlay: FileSelectorOverlay; 
// File selector input is placed as a sibling to provided target, so target 
// requires a parent element for the input to be reachable. 
this.fileSelectorOverlay = new FileSelectorOverlay(this.fileSelectorOverlayTarget, 
FileSelectorOverlay.SelectorType.MULTIPLE_FILE_SELECTION, ACCEPTED_TYPES as string[]); 
this.fileSelectorOverlay.listen (FileSelectorOverlay.EventType.SELECT, (e: 
FileSelectEvent) => { this.handleFileSelect(e); });

    'saglobal.getFileUploadInput', () => this.getFileUploadInput());


/**Returns the input element that triggers the file upload dialog. Exported globally for usage in web driver tests. */

private getFileUploadInput(): HTMLInputElement|undefined { return this.fileSelectorOverlayTarget.parentNode?.querySelector('input') || undefined; } Webdriver code

return_value = driver.execute_script("return saglobal.getFileUploadInput()") Error Message: stale element reference: stale element not found

Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share