我正在尝试在本地HTML字符串上运行Selenium,但似乎找不到任何关于如何这样做的文档。我从电子邮件API中检索HTML源代码,因此Selenium无法直接解析它。有没有办法修改以下内容,以便它可以读取下面的HTML字符串:
远程访问的Python代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_class_name("q")
本地HTML代码:
s = "<body>
<p>This is a test</p>
<p class="q">This is a second test</p>
</body>"