Get Source of WebElement in Selenium WebDriver (Python)?

There is not really a straight-forward way of getting the html source code of a webelement. You will have to use JS. I am not too sure about python bindings but you can easily do like this in Java.

I am sure there must be something similar to JavascriptExecutor class in Python WebElement element = driver. FindElement(By. Id("foo")); String contents = (String)((JavascriptExecutor)driver).

ExecuteScript("return arguments0. InnerHTML;", element).

There is not really a straight-forward way of getting the html source code of a webelement. You will have to use JS. I am not too sure about python bindings but you can easily do like this in Java.

I am sure there must be something similar to JavascriptExecutor class in Python. WebElement element = driver. FindElement(By.Id("foo")); String contents = (String)((JavascriptExecutor)driver).

ExecuteScript("return arguments0. InnerHTML;", element).

1 this is your best bet – prestomanifesto Sep 7 at 6:13 This is essentially what I ended up doing, albeit with the Python equivalent. – Chris W. Sep 7 at 21:15.

I hope this could help: selenium.googlecode.com/svn/trunk/docs/a... There is described Java method java.lang. String getText() But unfortunately in Python its not available. So you can translate the method names to Python from Java :-) and try another logic using present methods without getting the whole page source... E.g.

My_id = elem0. Get_attribute('my-id').

But that actually just returns the "plaintext" between HTML tags and won't actually return the full HTML source. – Chris W. Sep 7 at 21:17.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions