使用Cucumber和Selenium测试网站。在我的hooks.js文件中,我有以下内容:Selenium Webdriver Black屏幕截图PhantomJS
driver.get("https://localhost:8000/");
sleep(2000);
TakeScreenshot('./test_artifacts/img/', 'Load Success', driver);
var btn = this.driver.wait(selenium.until.elementLocated(By.css('#app > div > div > div.col-xs-6.textColumn > button'), seleniumTimeOut));
TakeScreenshot('./test_artifacts/img/', 'Load Success', driver);
this.driver.sleep(3000);
这里的目标是成功加载页面并截取它。该网站正在运行本地主机。发生截图时会出现问题。无论我有多长时间让司机入睡,我都会得到一张黑色的截图,表明我的网站没有及时“建立”(根据情况使用可能不正确的术语)。如果我更改URL,以https://google.com/我得到了现场,没有任何问题的屏幕截图
Waiting for element to be located By(css selector, #app > div > div > div.col-xs-6.textColumn > button)
Wait timed out after 20112ms
:然后我得到这个错误。有什么想法发生在这里?我的上述假设是否正确? 在此先感谢!