views:

240

answers:

1

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. Obviously print(text) will only print the orignal html source. How do I get to the results of the javascript?

+2  A: 

try this to get the content of a html element with id=your-id :

sel.get_eval("this.browserbot.getCurrentWindow().document.getElementById('your-id').innerHTML"
luc
thanks - but not sure what 'your-id' is suppose to be?
Seth
I guess that your javascript code insert the html code into something like a <div id="your-id"></div> tag.
luc
this is the line of javascript I am trying to get to: ` $create(AjaxControlToolkit.AutoCompleteBehavior, {"completionInterval":50,"completionListCssClass":"autocomplete_completionListElement","completionListItemCssClass":"autocomplete_listItem","completionSetCount":20,"delimiterCharacters":"","highlightedItemCssClass":"autocomplete_highlightedListItem","id":"ctl00_ContentPlaceHolder1_AutoCompleteExtender1","minimumPrefixLength":4,"serviceMethod":"GetSchoolNames","servicePath":"AutoComplete.asmx"}, {"itemSelected":ItemSelected}, null, $get("ctl00_ContentPlaceHolder1_SchoolNameTextBox"));`
Seth