How to make protractor press the enter key?
Keyup/Keydown is limited to modifier keys in WebDriver (shift, ctrl, etc). I think you want browser.actions().sendKeys(protractor.Key.ENTER).perform();
Keyup/Keydown is limited to modifier keys in WebDriver (shift, ctrl, etc). I think you want browser.actions().sendKeys(protractor.Key.ENTER).perform();
If you are behind a proxy, set it correctly in npm. >npm config set proxy http://proxyhost:proxyport >npm config set https-proxy http://proxyhost:proxyport Notes: For SSL/https proxies, the protocol in URL should be http not https If your set up is on a Docker/Vagrant instance or a hosted VM, use IP address instead of hostname for proxy … Read more
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
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
Depending on what you want to do, you can try: browser.waitForAngular(); or btnLoginEl.click().then(function() { // do some stuff }); to solve the promise. It would be better if you can do that in the beforeEach. NB: I noticed that the expect() waits for the promise inside (i.e. getCurrentUrl) to be solved before comparing.
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();
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
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
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
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