I am using this to add html between a div tag but it displays Unexpected token '<'
JavaScript
x
2
1
browser.execute_script("arguments[0].innerHTML = " + f'{x["solution"]}', solution)
2
The x["solution"]
is a json file which contains html like <strong> bold </strong>
etc.
Advertisement
Answer
You forgot to quote the right part of the equality. This code is generating:
JavaScript
1
2
1
arguments[0].innerHTML = <strong> bold </strong>
2
Also, you can use a single formatted string which would look like:
JavaScript
1
2
1
browser.execute_script(f'arguments[0].innerHTML = "{x["solution"]}"', solution)
2
and would generate
JavaScript
1
2
1
arguments[0].innerHTML = "<strong> bold </strong>"
2