[英]How do I get javascript results using selenium?
I have the following code: 我有以下代码:
from selenium import selenium
selenium = selenium("localhost", 4444, "*chrome", "http://some_site.com/")
selenium.start()
sel = selenium
sel.open("/")
sel.type("ctl00_ContentPlaceHolder1_SuburbTownTextBox", "Adelaide,SA,5000")
sel.click("ctl00_ContentPlaceHolder1_SearchImageButton")
#text = sel.get_body_text()
text = sel.get_html_source()
print(text)
The click executes a javascript file which then produces results on the same page. 点击执行一个javascript文件,然后在同一页面上生成结果。 Obviously
print(text)
will only print the orignal html source. 显然
print(text)
只会打印orignal html源代码。 How do I get to the results of the javascript? 我如何获得javascript的结果?
试试这个来获取id = your-id的html元素的内容:
sel.get_eval("this.browserbot.getCurrentWindow().document.getElementById('your-id').innerHTML"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.