使用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
:然後我得到這個錯誤。有什麼想法發生在這裏?我的上述假設是否正確? 在此先感謝!