What is browser.ignoreSynchronization in protractor?

The simple answer is that it makes protractor not wait for Angular promises, such as those from $http or $timeout to resolve, which you might want to do if you’re testing behaviour during $http or $timeout (e.g., a “loading” message), or testing non-Angular sites or pages, such as a separate login page. For example, to … Read more

Print message on expect() assert failure

UPDATE I see people still are finding this. Later information from the Jasmine team is that there is an undocumented feature on the expect – you can include a custom failure message and it just works: expect( fields[i].element.exists() ).toEqual(true, field[i].name + ‘ is expected to exist’); Which is exactly what I was originally looking for. … Read more

how to use Protractor on non angularjs website?

Another approach is to set browser.ignoreSynchronization = true before browser.get(…). Protractor wouldn’t wait for Angular loaded and you could use usual element(…) syntax. browser.ignoreSynchronization = true; browser.get(‘http://localhost:8000/login.html’); element(by.id(‘username’)).sendKeys(‘Jane’); element(by.id(‘password’)).sendKeys(‘1234’); element(by.id(‘clickme’)).click();

How to upload file in angularjs e2e protractor testing

This is how I do it: var path = require(‘path’); it(‘should upload a file’, function() { var fileToUpload = ‘../some/path/foo.txt’, absolutePath = path.resolve(__dirname, fileToUpload); element(by.css(‘input[type=”file”]’)).sendKeys(absolutePath); element(by.id(‘uploadButton’)).click(); }); Use the path module to resolve the full path of the file that you want to upload. Set the path to the input type=”file” element. Click on the … Read more

How to test if an element has class using Protractor?

One gotcha you have to look out for with using toMatch(), as in the accepted answer, is partial matches. For instance, let’s say you have an element that might have the classes correct and incorrect, and you want to test that it has the class correct. If you were to use expect(element.getAttribute(‘class’)).toMatch(‘correct’), that will return … Read more

Can Protractor and Karma be used together?

Not recommended by the current maintainer of Protractor: https://github.com/angular/protractor/issues/9#issuecomment-19927049 Protractor and Karma should not be used together; instead they provide separate systems for running tests. Protractor and Karma cover different aspects of testing – Karma is intended mostly for unit tests, while Protractor should be used for end to end testing. Protractor is built on … Read more

How to set default browser window size in Protractor/WebdriverJS

You can set the default browser size by running: var width = 800; var height = 600; browser.driver.manage().window().setSize(width, height); To maximize the browser window, run: browser.driver.manage().window().maximize(); To set the position, run: var x = 150; var y = 100; browser.driver.manage().window().setPosition(x, y); If you get an error: WebDriverError: unknown error: operation is unsupported with remote debugging … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)