admin管理员组文章数量:1355600
I am trying to programmatically click a button in a web page using the mand
document.getElementsByName("versionFile")[0].click()
while this mand works fine in the developer tool console (opens the file selector) i am not able to execute this in script because it gives me a error saying "File chooser dialog can only be shown with a user activation" highlighting the click() function
Can anyone hep me out with this.
I am trying to programmatically click a button in a web page using the mand
document.getElementsByName("versionFile")[0].click()
while this mand works fine in the developer tool console (opens the file selector) i am not able to execute this in script because it gives me a error saying "File chooser dialog can only be shown with a user activation" highlighting the click() function
Can anyone hep me out with this.
Share Improve this question edited Jan 27, 2022 at 23:48 QHarr 84.5k14 gold badges56 silver badges104 bronze badges asked Jan 25, 2022 at 11:35 KarnanKarnan 211 gold badge1 silver badge2 bronze badges 2- What does vba have to do with this? – QHarr Commented Jan 25, 2022 at 17:58
- Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Bot Commented Feb 3, 2022 at 10:32
2 Answers
Reset to default 2Most modern browsers restrict the JavaScript interactions not started by the user, to avoid annoying pages and make XSS a bit more difficult.
If you are using a web-scraping library like puppeteer
, you should interact with the page using it's API (using page.click
for example), not by injecting JavaScript on the page.
If that is not a option, you need to find the callback function that the button fires, and bypass the element.click()
method.
As of latest years, this is no longer working :
Chrome shows for such operations :
No js can do this anymore
本文标签:
版权声明:本文标题:File chooser dialog can only be shown with a user activation error while using web scraping through Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744030024a2578730.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论