-
Notifications
You must be signed in to change notification settings - Fork 2.3k
sendKeys() doesn't insert text because focus is on the address bar (firefox only) #1511
Comments
Right now i fixed by: this.fillLoginForm = function (email, pwd) {
var self = this;
this.getLoginModalUserEmail().clear().then(function() {
self.getLoginModalUserEmail().sendKeys(email);
});
this.getLoginModalUserPwd().clear().then(function() {
self.getLoginModalUserPwd().sendKeys(pwd);
});
// when the login button is enablead means that form is fulfilled
return expect(this.getLoginButton().isEnabled()).toBeTruthy();
}; Stil testing but seems working pretty well in Chrome and Firefox. |
How do you know that the input text-box isn't being set correctly? Though screenshots or some sort of assertion later? A couple other noes: You should be able to just do this like:
Also, unrelated but your selector raises some red flags. IDs in HTML should be unique, so you should never need to scope them. If you have multiple elements with id |
it('correct login', function() {
page.open();
page.openLoginModal();
page.fillLoginForm('a@a.aa', 'a');
page.confirmLogin();
page.checkRedirection(/profile/, 7000, 'redirection after login not performed');
page.logout();
}); page object: (function () {
var IndexPage = function () {
// GETTER elements: navbar
this.getNavBarRegistrationButton = function () {
return element(by.css('.navbar #sign-up-navbar > #navbar-registration-button'));
};
this.getNavBarLoginButton = function () {
return element(by.css('.navbar #navbar-login-button'));
};
// GETTER elements: navbar:dropdown
this.getNavBarDropDownMenu = function () {
return element(by.css('.user-menu .dropdown-toggle'));
};
this.getNavBarDropDownLogoutButton = function () {
return element(by.css('.user-menu .dropdown-menu #logout-link'));
};
// GETTER elements: modal:login
this.getLoginModal = function () {
return element(by.css('#loginModalView.modal'));
};
this.getLoginModalUserEmail = function () {
return element(by.css('#loginModalView.modal form[name="loginForm"] #input_email'));
};
this.getLoginModalUserPwd = function () {
return element(by.css('#loginModalView.modal form[name="loginForm"] #input_password'));
};
this.getLoginButton = function () {
return element(by.css('#loginModalView.modal .modal-footer > #modal-login-button'));
};
this.getLoginCloseButton = function () {
return element(by.css('#loginModalView.modal .modal-footer > #modal-close-button'));
};
// ACTIONS: global
this.open = function () {
browser.get('/view');
return browser.waitForAngular();
};
this.logout = function () {
this.getNavBarDropDownMenu().click();
browser.waitForAngular();
this.getNavBarDropDownLogoutButton().isDisplayed();
return this.getNavBarDropDownLogoutButton().click();
};
this.checkRedirection = function (targetRegex, timeout, message) {
// explicit wait
return browser.wait(function() {
return browser.driver.getCurrentUrl().then(function(url) {
return targetRegex.test(url); // look for a match of the regex /profile/ in the 'url'
});
}, timeout, message);
};
// ACTIONS: login
this.openLoginModal = function () {
this.getNavBarLoginButton().click();
browser.waitForAngular();
return this.getLoginModal().isDisplayed();
};
this.fillLoginForm = function (email, pwd) {
this.getLoginModalUserEmail().clear().sendKeys(email);
this.getLoginModalUserPwd().clear().sendKeys(pwd);
// when the login button is enablead means that form is fulfilled
return expect(this.getLoginButton().isEnabled()).toBeTruthy();
};
this.confirmLogin = function () {
return this.getLoginButton().click();
};
};
module.exports = function() {
return new IndexPage();
};
}()); I can run this test hundreds times FF e Chrome, right now i got very very few occurrences of the following in FF:
|
@tundo91 Would you be able to host your app (or the login portion of it) publicly so I can test it, and/or the source code for it. Enough people report it that i feel like it's a real issue, but I cannot reproduce this to determine the nature of the problem. |
Ok @hankduan let's use the staging at https://staging.eversnapapp.com/view, you can create random users using this.fillSignUpForm = function (name, email, pwd, pwdConfirm) {
var self = this;
// fill form
this.getRegistrationUserName().clear().sendKeys(name);
this.getRegistrationUserEmail().clear().sendKeys(email);
this.getRegistrationUserPwd().clear().sendKeys(pwd);
this.getRegistrationUserPwdConfirm().clear().sendKeys(pwdConfirm);
// when the register button is enablead means that form is fulfilled
return browser.wait(function () {
return self.getRegistrationRegisterButton().isEnabled();
});
}; Now run the registration test several times in Chrome and FF. I noticed that seems happening just with the first text input. I've same problem in the login form. |
This is great, thanks! I'll play with this tonight or tomorrow and let you know what I find (or whether I can reproduce it) |
Great waiting for you ✌️ |
While I haven't been able to reproduce yet, here are some observations I've made on your app (just so I know we're not doing something completely different).
(maybe you're testing a newer version or something?)
My suspicion on why the sendKeys aren't being sent is related to 3 -- if the modal have a small timeout-based animation in it, protractor's sendkeys won't actually send the keys until the timeout is over. What the clear did was just add a little delay. Try this: instead of adding clear like
do this:
like this:
or this:
|
|
Ok, I'll test tomorrow with your new version |
I can reproduce this =) That's a great first step -- like you said, chrome is fine; the problem produces itself in firefox. Now let me go try to see what's going on. |
@tundo91 This looks like an issue with webdriver/firefox (and perhaps how it's interacting with your page) Here's a raw webdriver test which exhibit the same behavior:
So the issue isn't with animation as I had original suspected, but with focus. I want to confirm with you to see if this is the behavior you see, but here's what I noticed: Basically I noticed during the test, as soon as webdriver opens up your app, the focus is on the url bar, until after the first sendKeys. Is it okay if I open an issue with webdriver using your app as an example? |
Confirmed:
@hankduan go ahead with the webdriver issue. Should this being closed? |
No let's keep it open so it's searchable. I feel like there are a few reports of this problem. |
@tundo91 Can you bring up the staging app at 'https://staging.eversnapapp.com/view' again (or let me know where it has moved to)? Webdriver just started looking at the issue, and it would be helpful if it is up again. |
I'm sorry but I'm not longer in that project i cannot do it :( |
I'm going to close this issue since I haven't seen any other reproducible reports of this, and I cannot provide a reproducible example to selenium. |
I'm experiencing this exact same behavior on Firefox 52. |
i am not able to enter value in Text box field using sendKeys in Safari browser of appium. Any solutions ? |
Hi there,
i'm testing a form login contained in a modal.
I'm using the Page Object so i get the element by this:
Sometimes
sendKeys(string)
function execute but the input text-box isn't filled up by the string!I can say that execute since
this.getRegistrationUserName().sendKeys(name).then(function() {console.log("done!");} )
actually prints done!)The weird is that i notice this issue just for the first input text-box of the form.
After looking #562 seems that executing
.clear()
on the text-box makesendKeys()
working well.Configuration:
The text was updated successfully, but these errors were encountered: