Selenium进行POST请求 发表于 2022-02-18 遇到一个需求,需要Selenium进行POST带参数请求,想到的方法是执行js脚本 12345678910111213141516171819ChromeDriver webDriver = new ChromeDriver();String script = "const form = document.createElement('form');\n" + "form.method = 'post';\n" + "form.action = '%s';\n" + " const hiddenField = document.createElement('input');\n" + " hiddenField.type = 'hidden';\n" + " hiddenField.name = 'pageSizeNow';\n" + " hiddenField.value = '10';\n" + "\n" + " form.appendChild(hiddenField);" + " const hiddenField1 = document.createElement('input');\n" + " hiddenField1.type = 'hidden';\n" + " hiddenField1.name = 'pageIndexNow';\n" + " hiddenField1.value = '%s';\n" + "\n" + " form.appendChild(hiddenField1);" + "document.body.appendChild(form);\n" + "form.submit();"; webDriver.executeScript(String.format(script, "https://alk.12348.gov.cn/LawMultiSearch/Search", page.toString())); 赏个🍗吧 打赏 微信支付 支付宝 本文作者: Keeep 本文链接: http://Keeep.coding.me/blog/Selenium进行POST请求/ 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!