protractor icon indicating copy to clipboard operation
protractor copied to clipboard

Element Validation within If Statement

Open magicode118 opened this issue 11 years ago • 1 comments

I'm having issues when adding an element validation within an if-statement.

Basically, irrelevant of the result of the if-statement, Protractor is still trying to find the element specified within the if-statement.

Here is the code that is still running even though the if-statement returned false:

            if (thisIsAlwaysFalse == true) {

                console.log(':::::::::::::::' + thisIsAlwaysFalse);
                it('If-statement test', function(done) {

                    var elementToFind= element(by.xpath('//td[contains(@class,"hello")]'));                  

                    browser.wait(function() {
                        return browser.isElementPresent(elementToFind);
                    }, 5000);            

                    elementToFind.click();

                    done();
                });        
            }

Also, funny thing is that the console.log part is successfully ignored!

Anyone has a solution for this or possibly knows why this is happening?

Thanks in advance :)

magicode118 avatar Jan 16 '15 15:01 magicode118

Please read the contributing guidelines; these types of questions are ill-suited for GitHub. Thanks!

juliemr avatar Jan 16 '15 18:01 juliemr