Selenium Webdriver PHP Unit, trying to fill in fields with masks, skips to end

97 views
Skip to first unread message

kristof van kriekingen

unread,
Sep 8, 2014, 8:03:32 AM9/8/14
to seleniu...@googlegroups.com

Selenium Webdriver PHP Unit, trying to fill in fields with masks, skips to end:

I have an issue and can't seem to solve it or find any documentation about it.
I found an example online here:
http://www.angelwatt.com/coding/masked_input.php

It's the SSN field: ...-..-.... it works somewhat the same field as I'm working with. Whenever you fill something in with selenium it hops towards the end.
I also tried to sendkeys 1 by 1 or use tabs etc. But it just hops towards the end of the field.

Is there anything that I can do to fill in fields like this?

$this->webDriver->get('http://www.angelwatt.com/coding/masked_input.php');
sleep(3);          
$this->webDriver->findElement(WebDriverBy::xpath('//*[@id="ex-3"]'))->click();
$this->webDriver->getKeyboard()->sendKeys('481878483');

Basically this issue on SO: http://stackoverflow.com/questions/24911185/filling-in-mask-fields-with-phpunit-selenium

Thanks in advance

PS: Any workaround is welcome

David

unread,
Sep 8, 2014, 2:30:50 PM9/8/14
to seleniu...@googlegroups.com
As a workaround, did you consider just force set the value using javascript rather than typing in the keys?

e.g. execute Javascript against this javascript code

document.getElementById('user_insz').value = "98121252182";

I don't know the particular javascript execution command for PHPUnit Selenium WebDriver but should be easy to lookup in the docs. Using this approach isn't natural/normal and you might not see the visual update to the field, however, this will always work in setting the value behind the scenes so that the next step (e.g. form submission) will work. However, not sure how that applies to masked fields though as I've never had to deal with that using this technique or sendKeys.

Another thing you might want to try/check is whether this issue happens only with the PHP binding, or whether writing equivalent code in Java, etc. will give you the same result so that you can confirm whether this is issue with Selenium or the PHP binding.
Reply all
Reply to author
Forward
0 new messages