TEXT FIELD VALIDATION

51 views
Skip to first unread message

Bavani sri

unread,
Jul 2, 2020, 12:35:42 AM7/2/20
to Selenium Users
Hai All,

Can someone please explain about how to validate text field for maximum and minimum words and characters?

Joe Ward

unread,
Jul 2, 2020, 3:09:10 AM7/2/20
to seleniu...@googlegroups.com
Doesn’t sound like a very good candidate for a Selenium test. You could always set the input, get the input back, count the characters? Or set the input and look for some kind of error. 

On Thu, 2 Jul 2020 at 05:35, Bavani sri <bavaa...@gmail.com> wrote:
Hai All,

Can someone please explain about how to validate text field for maximum and minimum words and characters?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/32a8a47f-eae7-44e1-a254-feba547fcc28o%40googlegroups.com.

Bavani sri

unread,
Jul 2, 2020, 3:30:10 AM7/2/20
to Selenium Users
I'am new to selenium automation and i need clarification not your criticize. We are here to learn together. Thank you :)


On Thursday, July 2, 2020 at 3:09:10 PM UTC+8, That Guy wrote:
Doesn’t sound like a very good candidate for a Selenium test. You could always set the input, get the input back, count the characters? Or set the input and look for some kind of error. 
On Thu, 2 Jul 2020 at 05:35, Bavani sri <bavaa...@gmail.com> wrote:
Hai All,

Can someone please explain about how to validate text field for maximum and minimum words and characters?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.

Joe Ward

unread,
Jul 2, 2020, 3:31:56 AM7/2/20
to seleniu...@googlegroups.com
Pardon? It’s not a criticism. Part of learning a tool is to learn when not to use a tool. The second part of my answer also answered your question. Not a great attitude to have my friend. 

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/87d807e3-2845-4619-9db5-598e6c9cb993o%40googlegroups.com.

Sai Krishna Pulivarthi

unread,
Jul 2, 2020, 3:37:10 AM7/2/20
to seleniu...@googlegroups.com
I agree with you. If you wanna criticise the new learners, just remove yourself from the mailing list. If you know share it, else you can simply ignore.. just a suggestion to everyone. 

If possible try to be positive and shed some light on the newbies.

Coming to your question: there is no definite way to validate the limitations.. because it depends on why type of data type your DEVs has used when defining the text box in Data base.. better to have your BA intervened and set a certain limit when developing and then you are test based on the limitations we have in place. 


To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/87d807e3-2845-4619-9db5-598e6c9cb993o%40googlegroups.com.
--
Thanks,
Sai

Joe Ward

unread,
Jul 2, 2020, 3:39:30 AM7/2/20
to seleniu...@googlegroups.com
I think you’ve mistaken just providing an answer in the form of a snippet of code, which is popular in this group but ultimately not that productive, with actually promoting people to think about how a tool should be used and signposting how to use the tool to get the answer you want. 

That being said thanks for your unsolicited advise, rest assured I will ignore it. 

Sai Krishna Pulivarthi

unread,
Jul 2, 2020, 3:43:58 AM7/2/20
to seleniu...@googlegroups.com
Generalising is the new trend these days.. I hope you see my answer just below my “unsolicited “ advice. I did not have any snippet there. I advised him it’s a waste of time to work on undefined text field. 

--
Thanks,
Sai

Joe Ward

unread,
Jul 2, 2020, 3:51:41 AM7/2/20
to seleniu...@googlegroups.com
If we want to split hairs about what a “useful” answer is I don’t think yours is all that great either. What does the input type have to do with character limits?

getElement(“someInput”).getAttribute(“maxlength”) will tell me what the maxlength is of a number input, a text input, a password input, basically any input that has maxlength defined. It’s also a bit odd to tell somebody to refer to a BA when you have no idea whether or not they are asking from a business perspective or just as a hobbyist trying out selenium. 

In fact that probably answers the OPs question. Get the element and make some kind of assertion against the maxlength attribute, which will be a number. 


Sai Krishna Pulivarthi

unread,
Jul 2, 2020, 3:57:17 AM7/2/20
to seleniu...@googlegroups.com
If you are pointing fingers, I never claimed I was a pro Selenium user, I never worked on a Selenium , I just gave my 2 cents as a fellow QA user. All these discussions would have never existed if you knew the answer before hand or you would have answered the same in the very first reply.. 

End of the it all boils down to how to react to things.. that guy who asked the being new here would not expect a reply like that. 

You need to be in his shoes if you ever need to understand how he would have felt. Anyways end of discussion and thanks for the answer.. :) 

--
Thanks,
Sai

Joe Ward

unread,
Jul 2, 2020, 3:59:22 AM7/2/20
to seleniu...@googlegroups.com
I am speaking “from somebody’s shoes”, if somebody taught you to hammer a nail using a spanner eventually you’d resent them for teaching you that wouldn’t you? Use the right tool at the right time. 

Anyway OP has his answer now and we all learned something valuable. 

Kind regards, have a nice day. 

Ripon Al Wasim

unread,
Jul 2, 2020, 7:49:26 AM7/2/20
to seleniu...@googlegroups.com
Hi Bavani sri,
As I have understood, you have a text field which has Minimum and Maximum characters to input. Say minimum chars is 6 and max chars is 32. You need to validate Boundary value. You can do it using Assertion. If you use Java with Selenium you can use TestNG or JUnit test framework which can help you for Assertion.
for checking Minimum chars:
driver.findElement(By.id("<IDOfTextFiled>")).sendKeys("123456");
String actualValue = driver.findElement(By.id("<IDOfTextFiled>")).getAttribute("value");
int actualNumberOfChars = actualValue.length();
int expectedNumberOfChars = 6;
assertEquals(actualNumberOfChars, expectedNumberOfChars);

In similar way, you can validate max no. of chars.

If the no. of chars are less than Min chars --> check the validation message
  If the no. of chars are more than Max chars --> check the validation message  

On Thu, Jul 2, 2020 at 10:35 AM Bavani sri <bavaa...@gmail.com> wrote:
Hai All,

Can someone please explain about how to validate text field for maximum and minimum words and characters?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

SuperKevy

unread,
Jul 2, 2020, 9:20:38 PM7/2/20
to Selenium Users
Everyone has shouted out while missing the point.    
I'm guessing you would expect any input that has boundaries to throw a (error) message to the screen which is what you can check for existence when you exceed the boundaries.
If the inputs don't error check for what it wants get a new requirement in place that defines the boundary .     
Manually check to see what messages appear on bad data submits, then code it up.

Bavani sri

unread,
Jul 3, 2020, 3:29:51 AM7/3/20
to Selenium Users
Thank you so much for your guidance. Appreciate it :)

That Guy

unread,
Jul 3, 2020, 3:51:22 AM7/3/20
to seleniu...@googlegroups.com
I don't think that point was missed, you'll notice it was in my original reply. :/                   

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

SuperKevy

unread,
Jul 4, 2020, 12:42:18 PM7/4/20
to Selenium Users
Sorry "that guy",   lost that comment in the flood of words and responses.   
We both should have said "what does the user see or experience when the boundaries are exceed".
i.e. Selenium (webdriver) is meant to replicate a user experience as close as possible.
 .  


On Friday, July 3, 2020 at 2:51:22 AM UTC-5, That Guy wrote:
I don't think that point was missed, you'll notice it was in my original reply. :/                   

On Fri, 3 Jul 2020 at 08:29, Bavani sri <bavaa...@gmail.com> wrote:
Thank you so much for your guidance. Appreciate it :)

On Friday, July 3, 2020 at 9:20:38 AM UTC+8, SuperKevy wrote:
Everyone has shouted out while missing the point.    
I'm guessing you would expect any input that has boundaries to throw a (error) message to the screen which is what you can check for existence when you exceed the boundaries.
If the inputs don't error check for what it wants get a new requirement in place that defines the boundary .     
Manually check to see what messages appear on bad data submits, then code it up.



On Wednesday, July 1, 2020 at 11:35:42 PM UTC-5, Bavani sri wrote:
Hai All,

Can someone please explain about how to validate text field for maximum and minimum words and characters?

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages