1

I would like to make code that embeds pdf files in a table on a viewed page in chrome. Ideally via Selenium Webdriver. Meaning I need to change html code on page from

<td align="center">&nbsp;</td>

to

<embed src="http://qwer.com/a.pdf" type = "application/pdf">

Now I have understood that you can launch JavaScript through driver.execute_script, but having no prior experience with JavaScript, I am stuck.

This is as far as I have gotten:

driver.execute_script("""document.evaluate('/html/body/div[9]/form/table/tbody/tr[10]/td[3]', document, null, XPathResult.ANY_TYPE, null).align="right";""")

This script has tried to select a cell in a html table via XPath and do a minor change - align. It failed.

I have been trying more dramatic things as well, but over time as I couldnt figure out even this simple one, I am pleading for help.

Thanks to any one with constructive criticism!

  • See https://stackoverflow.com/questions/39543237/python-selenium-modifying-the-source-code-of-a-webpage – sherdim Mar 14 '21 at 09:50

0 Answers0