3

I am sharing my spec file, the generated report contains only 'through Gmail Account' text but I want to add 'Password pop up' text and many other headings also. I tried by adding one more 'it' block contains password code but my code was not working. Please help me out I want to make report shows the headings for all test cases.

My spec file is:

describe('Login', function () {
    afterEach(function () {
        browser.ignoreSynchronization = false;     });
    it(' through Gmail Account', function () {  
        var GM = protractor.ExpectedConditions;  
        browser.get("http://folio3.github.io/eCareVault/#");
        //browser.driver.manage().window().maximize();
        var gmail = element(by.css('.ggl>img'));
        browser.wait(GM.visibilityOf(gmail), 5000);
        gmail.click();               
        browser.getAllWindowHandles().then(function (handles) {
        browser.switchTo().window(handles[1]);
        element(by.id("Email")).click();
        element(by.id("Email")).sendKeys('[email protected]');
        element(by.id("next")).click();
        element(by.id("Passwd")).click();
        element(by.id("Passwd")).sendKeys('click123');
        element(by.id("signIn")).click();
        browser.switchTo().window(handles[0]);
//Password popup
       var Password = element(by.model("anyvalue"));
       browser.wait(GM.visibilityOf(Password), 10000);
       Password.sendKeys("123");
       element(by.id("submit")).click();
       element(by.css('.overview' )).click();
       element(by.css('.edit' )).click();       element(by.xpath('html/body/div[1]/div/form/div/section[1]/div/div[1]/div/input')).click().clear().sendKeys('bob');    
        });
    }); 

1 Answer 1

2

You are definitely missing some test case grouping and a beforeEach() where you would navigate to an initial "Log In" page. You should have something along these lines:

describe('Login', function () {
    var GM;

    beforeEach(function () {
        GM = protractor.ExpectedConditions;;
        browser.get("http://folio3.github.io/eCareVault/#");
    });

    afterEach(function () {
        browser.ignoreSynchronization = false;     
    });

    it('should log in through Gmail Account', function () {  
        var gmail = element(by.css('.ggl>img'));
        browser.wait(GM.visibilityOf(gmail), 5000);
        gmail.click();          

        browser.getAllWindowHandles().then(function (handles) {
            browser.switchTo().window(handles[1]);
            element(by.id("Email")).click();
            element(by.id("Email")).sendKeys('[email protected]');
            element(by.id("next")).click();
            element(by.id("Passwd")).click();
            element(by.id("Passwd")).sendKeys('click123');
            element(by.id("signIn")).click();

            browser.switchTo().window(handles[0]);
        });
    });

    it('should log in using password', function () { 
       var Password = element(by.model("anyvalue"));
       browser.wait(GM.visibilityOf(Password), 10000);
       Password.sendKeys("123");
       element(by.id("submit")).click();
       element(by.css('.overview' )).click();
       element(by.css('.edit' )).click();       
       element(by.xpath('html/body/div[1]/div/form/div/section[1]/div/div[1]/div/input')).click().clear().sendKeys('bob');    
    }); 
});

You are also missing logging out (as an "after each" action?), actually testing things - making expectations using expect().

6
  • its not working as I did the same thing previously by separating test cases with 'it' blocks but after login the test fails it is not entering anything on encryption pop up. Commented Dec 20, 2016 at 6:21
  • @RozmeenAli how does it fail and on which line? Thanks.
    – alecxe
    Commented Dec 20, 2016 at 14:18
  • After login, it just logout from the system. The test case doesn't execute the password pop up test cases. Commented Dec 22, 2016 at 5:39
  • Message: Failed: Wait timed out after 100009ms Stack: Error: Wait timed out after 100009ms Commented Dec 22, 2016 at 5:40
  • @RozmeenAli ah, on this line browser.wait(GM.visibilityOf(gmail), 5000);? Are you sure the selector is correct?
    – alecxe
    Commented Dec 22, 2016 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.