Are you referring to Selenium RC? Your syntax is off as well, missing another pair of parenthesis. The correct RC method is something like this, using the browserbot object to access javascript DOM properties/attributes (e.g. innerHTML), which aren't natively exposed to Selenium for getAttribute().
selenium.getEval("this.browserbot.findElement(\"(//div[@id='searchtextPanel_wrap']/div[4]/div[4])[0]\").innerHTML");
If you were using WebDriver / Selenium 2, it's easier as
driver.findElement(By.xpath("(//div[@id='searchtextPanel_wrap']/div[4]/div[4])[0]")).getAttribute("innerHTML");
WebDriver gives you direct access to javascript DOM properties/attributes.
On Monday, December 10, 2012 5:37:06 AM UTC-8, sam wrote:
Hi All,
I am new to selenium, i want to get an innerHTML from my page. i didn't have div Id, so i am trying to get this through xpath. my xpath is given below
//div[@id='searchtextPanel_wrap']/div[4]/div[4]
Its working when i check this on firefox console with given below syntax
$x("//div[@id='searchtextPanel_wrap']/div[4]/div[4]")[0].innerHTML;
but cant with java.
selenium.getHtmlSource("//div[@id='searchtextPanel_wrap']/div[4]/div[4]")[0].innerHTML;