I am writing a small program to help me automate some repetitive tasks, but I encountered a small issue.
When I access a page, I can successfully reach the hidden page, but when I try to click a button for the next step, I get an ERR_HTTP2_PROTOCOL_ERROR. In DevTools, I see that a POST request is showing as failed.
I tried disabling HTTP/2 in ChromeDriver, and while the ERR_HTTP2_PROTOCOL_ERROR no longer appears, the POST action remains pending.
How can I resolve this?
I can access it normally on Chrome and proceed to the next step.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
import time
options = webdriver.ChromeOptions()
#options.add_argument("--disable-http2")
chrome_driver_path = r'.chromedriver.exe'
driver = webdriver.Chrome(service=ChromeService(chrome_driver_path), options=options)
try:
driver.get("about:blank")
script = """
var form = document.createElement('form');
document.body.appendChild(form);
form.method = 'post';
form.action = 'https://example.com/1/123';
var input1 = document.createElement('input');
input1.type = 'hidden';
input1.name = 'key';
input1.value = '11111';
form.appendChild(input1);
form.submit();
"""
driver.execute_script(script)
time.sleep(600)
except Exception as e:
print(f"error: {e}")
I have tried using chromedriver and geckodriver to access it manually, but it still fails
user27461491 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1