Looking for suggestion on inline script to drive/navigate web pages

Thanks in advance for your comment on following problem I am trying to resolve.

I need inline scripts/programs to drive a browser (any type) page, e.g. clicking on buttons and links, scrolling etc. It has to be inline as part of another web page on the same browser; so I can not use webdriver which is a separate executable and process. the solution is preferably written in rust, but others are welcome too.

Thanks again.
godadada

I'm not sure if I understand what you're trying to do, but ability of one regular webpage to do anything on another webpage is extremely limited in browsers on purpose.

Alternatively, you can bypass this security model by making your own browser extension.

All of the above is tightly coupled to DOM APIs, and therefore JavaScript, and there isn't much that Rust/WASM can help with there.

If you could use WebDriver APIs, then that's an entirely different story.

Kornel,

Thanks very much for your helpful insights, which are on the target what I am trying to resolve. Yes, I am using Iframe.
Based on my understanding of your input and other info I gathered, let me explore possible viable options and issues incurred. I would appreciate if you can comment on them.

Option DOM API in javascript does provides methods to trigger browser events, as indicated in code sample below.
var event; // The custom event that will be created

if (document.createEvent) {
event = document.createEvent("HTMLEvents");
event.initEvent("dataavailable", true, true);
} else {
event = document.createEventObject();
event.eventType = "dataavailable";
}

event.eventName = "dataavailable";

if (document.createEvent) {
element.dispatchEvent(event);
} else {
element.fireEvent("on" + event.eventType, event);
}

I may be able to use javascript code inside RUST as some lib provided that kind of hook. the issue may be it violates Same Origin and It also may cause unforeseeable issues when RUST/WASM embedded inside javascript is calling javascript function itself. I may create a test case to see if this approach viable.

Another possible option is to use webdirver in RUST, https://crates.io/crates/webdriver. I tried sample code before saw it requires install webdriver executable rather than using as a lib. I can not use webdriver executable. I may need to look into it again to see if api can be used or find sample webdriver api sample code.

Thanks again for your help.
Regards,
Godadada