I want to use html code instead of real request.
My code
from selenium import webdriver
import json
with open("user1.html") as html_file:
driver = webdriver.Chrome()
html_content = html_file.read()
driver.execute_script('document.write("{}")'.format(json.dumps(html_content)))
# also I tried to change "" with ''
# driver.execute_script("document.write('{}')".format(json.dumps(html_content)))
View user1.html here
I received error
javascript error: missing ) after argument list
I tried this, but it didn't help me Python: javascript error: missing ) after argument list
UPDATE Also I tried
from selenium import webdriver
import json
with open("user1.html") as html_file:
driver = webdriver.Chrome()
html_content = html_file.read()
driver.get("data:text/html;charset=utf-8,{html_content}".format(html_content=html_content))
print(driver.page_source)
But this code prints <html><head></head><body></body></html>