Validating a textbox input.

I have to validate a textbox that it should not contains only letters or alphabets or special character. It should be alphanumeric. Being new to selenium webdriver, I cam not able to write script forit. Please help
For example, it should not be AAA  AA, 123 5678, £$$ $%^ or combination of all.
It should be a proper UK post code.

manasi86 Train Asked on December 13, 2015 in Selenium WebDriver.
Add Comment
2 Answer(s)

try putting in all the values individually and submitting the form. Then verify the text of the error messages that you will get.


Virender Singh Professor Answered on December 16, 2015.
Add Comment

Reg. UK Post-codes, I will suggest following way:

1. Using selenium driver.getAttribute(“value”) / driver.getText() [whichever appropriate in your situation];
read the submitted value, may be store the string somewhere.
2. Now, instead of writing whole regEx validation algorithm yourself.
Using other driver open any of the public available website providing postcode validation (**Make sure you don’t flood external site & use considerably & appropriately ) ;

Go to postcode text field.
> Enter pCode reterived in step-1
> Put into their post-code field & search
> Check if correct result is returned.

3. continue accordingly.

laxmisomni Train Answered on December 17, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.