无法创建" if statement"在Jasmine JS的测试用例中

时间:2015-04-30 09:00:16

标签: javascript node.js selenium-webdriver jasmine protractor

我无法创造" if statement"在Jasmine JS的测试用例中。

错误是在错误的定位器上,但我很确定它是错误的

使用我的语法而不是因为错误的定位器。

**测试用例,注意"屏幕4"的代码块。 **

AttributeFactoryCreator

**量角器的错误**

describe ('Onboarding - English registration', function() {

    beforeEach(function(){
        browser.ignoreSynchronization = true;
    });

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

    it ('Enter to Home Page', function() {
        homePage();
    });

    it ('Click on the start button  onboarding - screen 1', function() {

        browser.driver.sleep(2000);
        element (by.id('START_BUTTON')).click();
        browser.driver.sleep(2000);
            expect (element(by.binding('industry[0]')).isPresent()).toBe(true);
        browser.driver.sleep(2000);
            captureScreen("onboarding-screen1");
        browser.driver.sleep(3000);
    });

    it ('onboarding - screen 2', function() {
        //TO-DO:
        //element.all(by.css('.industry input[type="radio"]')).get(Math.floor(Math.random() * 11)).click()
        //var randIndustry = "industry_" + Math.floor(Math.random() * (12 - 0 + 1));
        //browser.driver.sleep(2000);
        //$('.randIndustryr').click();

        element (by.css ("li.ng-scope.icon-laptop > label.ng-binding")).click();
        browser.driver.sleep(1000);
        element (by.xpath("//div[1]/div/main/div[3]/section/div/form/div[1]/section[2]/div/ul/li[4]/label")).click();
        browser.driver.sleep(2000);
        element (by.css('input.btn')).click();
        browser.driver.sleep(3000);
            expect (element(by.css('form.ng-pristine.ng-valid')).isPresent()).toBe(true);
            captureScreen("onboarding-screen2");
        browser.driver.sleep(3000);
    });

    it ('onboarding - screen 3', function() {
        element (by.xpath("//div[1]/div/main/div[3]/section/div/section/form/div[1]/div[2]/input")).click();
        browser.driver.sleep(3000);
        element (by.css("input.btn")).click();
        browser.driver.sleep(3000);
            expect (element(by.id('user_email')).isPresent()).toBe(true);
            captureScreen("onboarding-screen3");
        browser.driver.sleep(3000);
    });

    it ('onboarding - screen 4', function() {
        var buttonNotPresent = expect (element (by.xpath("//div[@id='root_content']//button[.='Preview on your website']")).isPresent()).toBe(true)

        element(by.id("user_email")).sendKeys("auto" + Math.floor(Math.random()*11111) + "@vcita.com");
        element (by.id("business_name")).sendKeys("automation man");
        browser.driver.sleep(3000);
        element (by.className("input.btn btn-account-action btn-xl")).click().then(function (buttonNotPresent) {
                browser.driver.sleep(3000);
            if (buttonNotPresent === false) {
                element(by.id("user_email")).click();
                browser.driver.sleep(1000);
                element(by.xpath("//div[@class='step-content']/section/form/fieldset/div[4]/input")).click();
                captureScreen("onboarding-screen4");
                browser.driver.sleep(3000);
            };
        });

                // else {
                    browser.driver.sleep(3000);
                    expect (element(by.xpath("//div[@id='root_content']//button[.='Preview on your website']")).isPresent()).toBe(true)
                    captureScreen("onboarding-screen4");
                // };
    });

    it ('onboarding - screen 5', function() {
        browser.driver.sleep(10000);
        element (by.xpath("//div[@id='root_content']//button[.='Preview on your website']")).click();
        browser.driver.sleep(3000);
            expect (element(by.css('.uber-form-inner-content')).isPresent()).toBe(true);
            captureScreen("onboarding-screen5");
        browser.driver.sleep(3000);
    });

    it ('onboarding - screen 6', function() {
        element(by.name("url")).sendKeys("www.mysite.com");
        browser.driver.sleep(1000);
        element(by.xpath("//div[@class='row']/div[2]/input")).click();
        browser.driver.sleep(5000);
            expect (element(by.xpath("//div[@id='livesite_active_engage']/div/div/div[1]")).isPresent()).toBe(true);
            captureScreen("onboarding-screen6");
        browser.driver.sleep(3000);
    });

    it ('onboarding - screen 7', function() {
        browser.driver.sleep(3000);
        element (by.xpath("//div[@class='btns']//button[.='Done']")).click();
        browser.driver.sleep(5000);
            expect (browser.driver.getCurrentUrl()).toContain('vcita.com/my/dashboard');
        browser.driver.sleep(3000);
            captureScreen("onboarding-screen7");
        browser.driver.sleep(3000);
    });
});

1 个答案:

答案 0 :(得分:0)

你可以尝试的第一件事是lint你的代码。 我注意到你丢失了一些分号并通过这个在线工具运行代码:

http://www.javascriptlint.com/online_lint.php

它显示你缺少一些分号和一些额外的。亲自尝试一下,看看它是否有帮助。