0
我正在爲使用量角器的非角度js網站創建測試腳本。我的代碼如下:如何等待網站使用量角器完全加載
var co = require('co');
var path = require('path');
describe("TEST", function() {
it("test", co.wrap(function*() {
browser.ignoreSynchronization = true;
yield browser.get(URL, 60000);
browser.sleep(5000);// I want to remove the sleep statements
var elmOK = browser.driver.findElement(by.css('a[href="#login"]'));
yield elmOK.click();
expect(browser.getCurrentUrl()).toContain("login");
yield browser.switchTo().frame('here-account-sdk').then(function() {
browser.driver.findElement(by.id('sign-in-email')).sendKeys("uid");
browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("password");
browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click();
});
browser.sleep(5000);// I want to remove the sleep statements
var elmOK = browser.driver.findElement(by.xpath('//*[@id="lnav"]/li[3]/a'));
yield elmOK.click();
browser.sleep(1500);// I want to remove the sleep statements
browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[1]/select/option[2]')).click();
browser.sleep(5000);// I want to remove the sleep statements
browser.driver.findElement(by.xpath('//*[@id="administration"]/div/div[2]/table/tbody/tr[1]/td[10]/span')).click();
browser.sleep(5000);// I want to remove the sleep statements
browser.driver.findElement(by.xpath('//*[@id="content"]/div/div[2]/div/div/div/div[3]/button[1]')).click();//Delete the file
browser.sleep(5000);// I want to remove the sleep statements
}));
});
如果我在我的代碼中添加睡眠,測試按預期運行。但我想徹底刪除我的代碼中的睡眠聲明。我提到了許多其他堆棧溢出問題,但它沒有幫助。 :(
我第一次使用browser.manage().timeouts().implicitlyWait(5000);
但我認爲是在載入我的網址沒有延遲。
我用料的條件,但它也不能正常工作。
我加browser.wait(1000)
但我的腳本失敗,請。諮詢我,因爲我覺得這個問題有點失落