1

I am trying to automate a non angular js website with protractor.In order to locate the elements I have used xpath. But inorder to run my testproperly I have used browesr.sleep() which I believe is not a good way to code the test scripts. Can anyone tell me what should be promise statement be?

var co = require('co');

var path = require('path');

describe("Supplier Portal: Partner Login ", function () {

    it("test", co.wrap(function* () {
        browser.ignoreSynchronization = true;  // or false
        browser.driver.manage().deleteAllCookies();
        yield browser.get('URL');
        **browser.sleep(4000);**
        var elmOK = browser.driver.findElement(by.css('a[href="#partner"]'));
        yield elmOK.click();
        expect(browser.getCurrentUrl()).toContain("partner");
        yield browser.switchTo().frame('here-account-sdk').then(function () {
            browser.driver.findElement(by.id('sign-in-email')).sendKeys("masterauthor1@gmail.com");
            browser.driver.findElement(by.id('sign-in-password-encrypted')).sendKeys("voting123");
            browser.driver.findElement(by.xpath(' //*[@id="sign-in-form"]/div[2]/div[6]/form/fieldset[3]/button')).click();

        });
        **browser.sleep(5000);**
        browser.driver.findElement(by.xpath('//*[@id="partner"]/div/div[1]/form/div[1]/div[2]/div/input')).sendKeys("TEST");//company name
        browser.driver.findElement(by.xpath('//*[@id="region"]/option[3]')).click();//region name
        browser.driver.findElement(by.xpath('//*[@id="country"]/option[105]')).click();//country name
        browser.driver.findElement(by.xpath(' //*[@id="datatype"]/option[13]')).click();
        browser.driver.findElement(by.xpath('//*[@id="partner"]/div/div[2]/div[1]/div[3]/label/input')).click();//check box
        browser.driver.findElement(by.xpath('//*[@id="comment"]/div/textarea')).sendKeys("TEST");//Test area
        // browser.driver.findElement(by.xpath('//*[@id="partner"]/div/div[2]/div[2]/button[2]')).click();

        **browser.sleep(5000);**

        var fileToUpload = './TEST.txt';
        var absolutePath = path.resolve(__dirname, fileToUpload);
        $('input[type="file"]').sendKeys(absolutePath);
        browser.driver.findElement(by.xpath('//*[@id="partner"]/div/div[2]/div[2]/button[1]')).click();

        **browser.sleep(5000);**
    }));

I have read articles to include explicit wait in protractor but it didn't worked for me.

Jatin
  • 660
  • 3
  • 8
  • 28
  • Possible duplicate of [Want to remove Browser.sleep()](http://stackoverflow.com/questions/40583699/want-to-remove-browser-sleep) – mvndaai Nov 15 '16 at 00:23

0 Answers0