Scenario:
– We have registration form that checks for errors via AJAX
– Fields are: email, confEmail, fname, lname, pwd, confPwd
– Error check happens when user enters in “email” field and tabs to “confEmail” field. Same for “pwd” and “confPwd” field
– I am trying to write automation script that mimics user behavior where user will enter “test” in “email” field and then tab to next field which is “confEmail”. This should invoke AJAX check and throw error about “invalid email address”
Test configuration:
– Test written in Linux
– Running in iPhone simulator on Mac (of course)
This piece of code enters email address:
driver.findElement(By.cssSelector(Locators.getLocator(“mobilebuy->emailAddressField”))).sendKeys(“test”);
Since sendKeys will not move focus away from that field, I then send TAB/click to next field so that the AJAX fires up. Apparently, doing that doesn’t work. The AJAX never fires and no error message shows up. I can see when I simulate this manually in iPhone simulator, it works.
This should tab to next field:
driver.findElement(By.cssSelector(Locators.getLocator(“mobilebuy->emailAddressField”))).sendKeys(Keys.TAB);
OR
This should click on next field which should fire AJAX:
driver.findElement(By.cssSelector(Locators.getLocator(“mobilebuy->confEmailAddressField”))).click();
ANY IDEA ON HOW TO PROCEED WITH THIS ISSUE? I LOOKED THROUGH IT CLOSELY AND EVEN TRIED TO PASS IN UNICODE FOR “TAB” KEY BUT THAT DIDN’T WORK EITHER.
First of all, only the FirefoxDriver supports Action class (according to http://code.google.com/p/selenium/wiki/TipsAndTricks), but you should also expect support for the InternetExplorerDriver too.
Got this to work using following steps:
– I have a Type method which types items into the form
– Thereafter, I send a click to the field that fires Ajax using Action class and that seemed to work