3

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?

1 Answer 1

4

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"
Sign up to request clarification or add additional context in comments.

2 Comments

I guess that your javascript code insert the html code into something like a <div id="your-id"></div> tag.
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")); `

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.