Can't create "if statement" inside test case in Jasmine JS
I cannot create an "if statement" inside my Jasmine JS test case.
The error is on the wrong locator, but I'm sure there is something wrong.
with my syntax, not the wrong locator.
** In the test case, notice the "screen 4" code block **
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);
});
});
** Protractor error **
<failure type="expect" message="Expected false to be true.">
Error: Failed expectation at [object Object].<anonymous> (c:\automation\tests\onboarding.js:59:132) at C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd\index.js:94:14 at [object Object].promise.ControlFlow.runInFrame_ (C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20) at [object Object].promise.ControlFlow.runEventLoop_ (C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1755:8) at [object Object].<anonymous> (C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:2056:12) at goog.async.run.processWorkQueue (C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:125:21)
</failure>
<failure type="expect" message="Expected false to be true.">
Error: Failed expectation at [object Object].<anonymous> (c:\automation\tests\onboarding.js:77:111) at C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\jasminewd\index.js:94:14 at [object Object].promise.ControlFlow.runInFrame_ (C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1877:20) at [object Object].promise.ControlFlow.runEventLoop_ (C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:1755:8) at [object Object].<anonymous> (C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver\promise.js:2056:12) at goog.async.run.processWorkQueue (C:\Users\idan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\async\run.js:125:21)
+3
source to share
1 answer
The first thing you might try is your code. I noticed that you are missing half-columns and checked the code through this online tool:
http://www.javascriptlint.com/online_lint.php
This showed that you had a few half columns, and some additional ones. Try this for yourself and see if it helps.
0
source to share