Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xpath of element on another website/cross domain

I want to get the XPATH of an element on a website (my own domain), which I got it using JavaScript code as mentioned in this answer.

Now what I want to click on button which will open a url (cross domain) window and when user click on an element on that window it's XPATH is captured.

I tried doing the same using iframe with no luck.

Now my question is there a way to get the XPATH of an element of another website/ Cross domain?

like image 908
Arpit Aggarwal Avatar asked Jul 16 '15 10:07

Arpit Aggarwal


1 Answers

Sorry this is not possible without cooperation from the other (x-domain) site. Browsers are designed not to allow access to the DOM of x-domain documents (iframe included) for security reasons.

If you had cooperation from the other site, they could load your javascript file and then use postmessage to pass the xpath to the original page.

Other options would be to create a bookmarklet users could use on the other page, or a browser extension (Chrome and FF are pretty easy to develop for)... depends on your use case.

like image 199
Adam Heath Avatar answered Nov 25 '22 01:11

Adam Heath