How to verify the limit of characters of a textbox

2,486 views
Skip to first unread message

ritika ritu

unread,
Aug 14, 2015, 5:12:28 AM8/14/15
to Selenium Users
I have to verify a textbox limit.Can anyone tell me how to check the limit of a textbox in selenium

sunny sachdeva

unread,
Aug 14, 2015, 6:03:48 AM8/14/15
to Selenium Users

If you already know the char limit, then input the text which is more than the permissible limit. For ex if max char limit is 30 then send a text with 31 and then fetch the text and count the number of character. It should be 30

Hope this helps.

Thanks
Sunny

ritika ritu

unread,
Aug 14, 2015, 6:16:54 AM8/14/15
to seleniu...@googlegroups.com
Can you tell the code for it????

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/OSttsllLXEw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/fbf9b37f-d6e0-4128-9a0f-2bbfd712d4fd%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Ripon Al Wasim

unread,
Aug 14, 2015, 6:22:32 AM8/14/15
to seleniu...@googlegroups.com
Consider the limit is 30 char. The code should be following:

driver.findElement(By.id("textfieldID")).sendKeys("RiponAlWasim_RiponAlWasim_RiponAlWasim_RiponAlWasim_RiponAlWasim");//input should be greater than 30 chars
int actualLimit = driver.findElement(By.id("textfieldID")).getText().length();
assertEquals(actualLimit, 30);


br,
Ripon

--
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 post to this group, send email to seleniu...@googlegroups.com.

ritika ritu

unread,
Aug 14, 2015, 6:30:35 AM8/14/15
to seleniu...@googlegroups.com
This is Giving an error @Ripon

Ripon Al Wasim

unread,
Aug 14, 2015, 6:37:20 AM8/14/15
to seleniu...@googlegroups.com

ritika ritu

unread,
Aug 14, 2015, 6:40:08 AM8/14/15
to seleniu...@googlegroups.com
Do I need to create a method for it

error.png

Ripon Al Wasim

unread,
Aug 14, 2015, 6:41:46 AM8/14/15
to seleniu...@googlegroups.com
u can write this code inside your test method.

Mercious

unread,
Aug 14, 2015, 7:00:11 AM8/14/15
to Selenium Users
What the actual f*** dude.

Do you know how to code? 

And you need to change the ID too, of course. He only gave an example as ID, he doesnt even know what the ID of your actual website is. 

The website that you are testing doesnt use the example-ID that he used in his code example.

They are called "name", "org", etc. 

ritika ritu

unread,
Aug 14, 2015, 7:04:06 AM8/14/15
to seleniu...@googlegroups.com
This group is not for vulgur words...

--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/OSttsllLXEw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Kaleem Uddin Mohammed Abdul

unread,
Aug 14, 2015, 8:03:36 AM8/14/15
to Selenium Users
Mercious, author of the post is not dude instead dudette.

Ritu- If your developer has set maxlength property on the input then one line of code should be enough to check the length.
_WebDriver.findElement(By.id("IdOfTheControl")).getAttribute("maxlength").equals("ExpectedLength")


On Friday, August 14, 2015 at 2:42:28 PM UTC+5:30, ritika ritu wrote:

Mercious

unread,
Aug 14, 2015, 10:23:36 AM8/14/15
to Selenium Users
It's for people that want to learn. "Please sponfeed me the solution!!!" is not learning.

Trying to use Selenium whilst havent not even basic programming knowledge is simply not going to lead anywhere productive. 

@Kaleem
Explains. 

krishnan.ma...@gmail.com

unread,
Aug 14, 2015, 10:44:03 PM8/14/15
to seleniu...@googlegroups.com

Mercious

Please tone down your responses. The selenium core dev community have always encouraged folks in thus forum to be gentle.
If a question is irking you, feel free to ignore it.

There are no silly questions in this forum. There are only silly answers.

Lets try and help each other out than lashing out at folks!

-Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else"

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 post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAFYgPAfpWX%2BHHUXe%2Bbpp02YpVFVRM-1ixU%3DjLhnX_%2BqLJ3jjXw%40mail.gmail.com.

Sridhar U

unread,
Aug 17, 2015, 2:50:48 PM8/17/15
to Selenium Users
Yes I Agree with Krishnan.

@Mercious - Buddy we are here to help each other.If you feel this is a silly question you can ignore - rather reacting in odd way you would have gave the guidance or ask the user to refer to the basics of the language and the usage of selenium (by providing a link) else you can ignore.  We are not pointing anything here to you but it should be general courtesy. Hope you will take this as a friendly advise.

@Ritu: Hope you got the answer for you question. However I would recommend you to get the knowledge on the Java and using selenium.

Let's leave this here.

Thanks,
Sri

ritika ritu

unread,
Aug 17, 2015, 3:50:16 PM8/17/15
to seleniu...@googlegroups.com
Hi all,
Thanks for your suggestion but I will say one thing again please give your answers if you want to help each other.
If you don't want to give answer then ignore but don't use any words it might embarrace someone.
Thank you..

For more options, visit https://groups.google.com/d/optout.


--
Sent from Gmail Mobile
Reply all
Reply to author
Forward
0 new messages