SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.7k stars 8.19k forks source link

[🚀 Feature]: Export backend code object or function to browser. #11194

Closed MiyamuraMiyako closed 2 years ago

MiyamuraMiyako commented 2 years ago

Feature and motivation

it's add js invoke backend capability.

Usage example

For example, I use C# backend:

EdgeOptions op = new EdgeOptions();
var esrv = EdgeDriverService.CreateDefaultService(".\\", "msedgedriver.exe");
var drv = new EdgeDriver(esrv, op);

drv.AddBackendObjectToJs("objectName", new JsInvokeMethodClass());

and Js:

objectName.xxxfunction();
github-actions[bot] commented 2 years ago

@MiyamuraMiyako, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

diemol commented 2 years ago

I am not really understanding what you mean. Is it to add a JS script that executes in the browser?

MiyamuraMiyako commented 2 years ago

@diemol It's similar to cefsharp or electron, browser can execute c# or nodejs code.

diemol commented 2 years ago

Can you share a link or an example to understand better?

MiyamuraMiyako commented 2 years ago

example: https://stackoverflow.com/questions/51259813/call-c-sharp-function-from-javascript-using-cefsharp-in-windows-form-app

or

https://www.c-sharpcorner.com/article/communication-between-winforms-application-and-web-application-using-cefsharp-br/

diemol commented 2 years ago

Thanks for sharing the links. That is out of the scope of this project. In the upcoming standard https://github.com/w3c/webdriver-bidi, there will be a way to register a JS function from the C# code (and other languages as well), but not the other way around.

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.