Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

programmatically click an input button in another web page?

I know there have been several similar questions, but I haven't seen an answer to my specific need: Is there a way to click a button in a separately launched web page? For example, I launch another web page via:

  • <a href="x" target="y"> or
  • window.open()

Can I then click an input button in that launched web page programmatically?

like image 378
Chuck Han Avatar asked Jul 13 '11 20:07

Chuck Han


People also ask

How will you click a button in web pages?

We can find the button on the web page by using methods like find_element_by_class_name(), find_element_by_name(), find_element_by_id() etc, following which we can click on it by using the click() method.

Can JavaScript click a button programmatically?

To click a button programmatically with JavaScript, we can call the click method. const userImage = document. getElementById("imageOtherUser"); const hangoutButton = document. getElementById("hangoutButtonId"); userImage.

How to simulate a click in HTML?

HTML DOM Element click()The click() method simulates a mouse-click on an element. This method can be used to execute a click on an element as if the user manually clicked on it.

How to make click event in JavaScript?

click() method simulates a mouse click on an element. When click() is used with supported elements (such as an <input> ), it fires the element's click event. This event then bubbles up to elements higher in the document tree (or event chain) and fires their click events.


1 Answers

Unless the page is underneath your own control or resides on the same domain then no, it is not possible. This would be cross-site scripting and all browsers have security sandboxes in place to keep something like this from happening. Why are you trying to programmatically press a button on a page that you're also programmatically opening?

like image 144
MoarCodePlz Avatar answered Oct 13 '22 17:10

MoarCodePlz