Getting innerHTML of an element using RemoteWebDriver

As of now there is no straightforward way to get innerHTML of an element using RemoteWebDrive in any of the languages but we can get it using the javascript way

/*
Way to get innerHTML
instead of xPath we can use any identifiers*/
WebElement Element = driver.findElement(By.xpath("//div[@id='foo']"));
 String innerhtml = (String)((JavascriptExecutor)driver).executeScript("return arguments[0].innerHTML;", Element);

 

You may also like...