This works for me; you had a bug on JavaScriptExecutor with an uppercase S Instead, you should have a JavaScriptExecutor with a lowercase S
Try this code:
import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; public class GetDomain_JS { public static void main(String[] args) { WebDriver driver=new FirefoxDriver(); driver.get("http://only-testing-blog.blogspot.in/2013/11/new-test.html"); driver.manage().window().maximize(); System.out.println(driver.getCurrentUrl()); JavascriptExecutor js=(JavascriptExecutor) driver; String domain_name=(String) js.executeScript("return document.domain"); System.out.println(domain_name); } }
It works for me !! Please click the green mark if it is for you!
pelican
source share