Currently, I am utilizing Selenium WebDriver and Protractor to execute end-to-end tests on my angular project. My main struggle lies in finding a detailed API that provides clear guidance on how to effectively use the driver. The specific issue I am encountering is as follows:
Within one page, I have two controllers - a login controller and a register controller. Both of them are connected to an input field bound to user.username. When testing the login functionality, I employ the following code:
element(select.model('user.username')).sendKeys('nathanadmin');
However, I receive a warning stating:
more than one element found for locator by.model("user.username") - you may need to be more specific
This becomes problematic when attempting to test the registration process, as I am unsure how to specifically select the second 'user.username' input.
I have explored resources such as: https://github.com/angular/protractor/blob/master/docs/api.md
And also referenced: http://docs.seleniumhq.org/docs/03_webdriver.jsp
Regrettably, I have yet to discover a comprehensive API offering a straightforward explanation on handling more complex element selection requirements.
EDIT:
I believe a solution like this could prove beneficial:
element(select.model('user.username').first()).sendKeys('nathanadmin');
My initial approach was:
element.all(select.model('user.username')).then(function(elements) { elements[0].sendKeys('nathanadmin'); });
Despite this attempt, I still find myself seeking a more thorough documentation on webdriver functionalities.