You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document adoptContext for JavaScript extensions - #21
Documents adoptContext from MarketSquare/robotframework-browser#5318 on the JavaScript extensions page. The code is planned for Browser 20.7.0, so please merge this together with that release.
The names Browser fills in: the table gets adoptContext.
New section "Handing over a context you created": an Electron example, what adoptContext registers and returns, how the context is closed, and when onClose runs. A note says that Browser itself does not support Electron or Android.
"Which extension point?": the table gets a row for platforms that Browser does not launch.
Correction in "Custom selector strategies":
The warning said that every JavaScript extension keyword needs an open browser and fails with Browser has been closed.
Since 20.4.0, only keywords that take page, context or browser need one, and the message is No Browser is open but needed for this operation.
The new section relies on this, so the page now states it once below the table of names. The example's comment is removed.
I ran the selector example both ways against Browser 20.6.0, registering before and after New Browser. The selector worked in both.
The :since marker says 20.7.0, the milestone that is open now. pnpm verify passes.
The section "From a library written in Python" describes adopted_context_options, register_adopted_context and AdoptedContextOptions from MarketSquare/robotframework-browser#5326, so this PR should not be merged before that one. pnpm verify still passes.
AI / tooling disclosure
This contribution was prepared with assistance from Claude Code (Anthropic). I reviewed the result manually, understand the changes, verified them locally, and confirm that I have the right to submit this contribution under the project license.
Documents adoptContext from MarketSquare/robotframework-browser#5318, planned for Browser 20.7.0. The custom selector warning is corrected: since 20.4.0, only keywords that take page, context or browser need an open browser.
adoptContext takes the optional name, headless and onClose, and an adopted context gets Browser's timeout. The concepts page names adopted contexts among the browsers that close together with their context.
adoptContext no longer sets the library timeout. Extension functions can request defaultTimeout like the other injected names and set it on the context they adopt; the Electron example does so.
A library written in Python gets the tracing and recording options of an adopted context from adopted_context_options and registers the context with register_adopted_context.
The method of the example library is decorated with @Keyword, so that Robot Framework sees it, and the JavaScript module exports its function. The summary counts the seven names that Browser fills in.
If waiting for the first window or adopting the context fails, this launched Electron process is never handed to Browser and therefore cannot be cleaned up by Close Browser or automatic closing. Close the application on this error path (and kill it if graceful close fails) so a failed launch keyword does not leak a process.
This issue also appears on line 239 of the same file.
…d launch
The Python example types its arguments with Browser's types, so that Robot Framework converts them as for New Context. A note says that a real module closes the application when anything after the launch fails.
The subclass never registers electron.js, so call_js_keyword("launchElectronApplication", ...) has no Node-side function to invoke and this Python-library example fails as shown. Initialize the module in the subclass before calling it; using init_js_extension also avoids exposing a second Robot keyword with the same name as this wrapper.
About the note in the last review that the Python example never loads electron.js: the page shows two ways to do the same thing, a JavaScript extension loaded with jsextension and a library written in Python. Each example shows only its own part, so the Python one leaves out how the library loads its module, for example with init_js_extension. I left it as it is.
This branch has not been deployed
No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Documents
adoptContextfrom MarketSquare/robotframework-browser#5318 on the JavaScript extensions page. The code is planned for Browser 20.7.0, so please merge this together with that release.adoptContext.adoptContextregisters and returns, how the context is closed, and whenonCloseruns. A note says that Browser itself does not support Electron or Android.Browser has been closed.page,contextorbrowserneed one, and the message isNo Browser is open but needed for this operation.New Browser. The selector worked in both.The
:sincemarker says 20.7.0, the milestone that is open now.pnpm verifypasses.The section "From a library written in Python" describes
adopted_context_options,register_adopted_contextandAdoptedContextOptionsfrom MarketSquare/robotframework-browser#5326, so this PR should not be merged before that one.pnpm verifystill passes.AI / tooling disclosure
This contribution was prepared with assistance from Claude Code (Anthropic). I reviewed the result manually, understand the changes, verified them locally, and confirm that I have the right to submit this contribution under the project license.