g1879 / DrissionPage

基于python的网页自动化工具。既能控制浏览器,也能收发数据包。可兼顾浏览器自动化的便利性和requests的高效率。功能强大,内置无数人性化设计和便捷功能。语法简洁而优雅,代码量少。
https://drissionpage.cn
BSD 3-Clause "New" or "Revised" License
7.87k stars 752 forks source link

How to convert Selenium driver.execute_script("document.getElementById('gpay-button-online-api-id').click()") to DrissionPage #386

Open tunght2406 opened 1 week ago

tunght2406 commented 1 week ago

image image

I tried using the command below but it didn't work: btn_buy = page.ele("#gpay-button-online-api-id").click() page.run_js("document.getElementById('gpay-button-online-api-id').click()")

I opened Devtool as shown in the picture and executed the command below and it was successful: "document.getElementById('gpay-button-online-api-id').click()"

So can I use the javascript command: "document.getElementById('gpay-button-online-api-id').click()" for drissionpage? Please help

wxhzhwxhzh commented 5 days ago

page.run_js("document.getElementById('gpay-button-online-api-id').click()")

tunght2406 commented 5 days ago

page.run_js("document.getElementById('gpay-button-online-api-id').click()")

I used it but not working