我是自动化测试的新手。在我的代码中,我在Selenium自动化测试脚本(使用JUnit)上使用了JavaScript。我正在尝试查找当前窗口标题:
driver = new ChromeDriver();
js = (JavaScriptExecutor)driver;
driver.get(//passed url);
//after the log in my Org. I execute the command below
//to get the title of the current window I execute the below command
js.executeScript("document.getElementsByTagName('title').innerHTML;");
,但上面的命令将返回作为获取窗口标题的空瞬间的答案。有人知道我的命令出了什么问题吗?
但我在页面的控制台日志上获得了执行时窗口的标题。所以我不知道我的代码出了什么问题。
谢谢。
莫汉·拉杰·S。
https://stackoverflow.com/questions/48059614
复制相似问题