1

I'm using python selenium to automate data input on a website, The issue is that one of the fields is set to have a max length of characters "30",

<input data-qa="input-LogId" data-testid="input-LogId" name="LogIDs" type="text" class="input-group__input " maxlength="30" value="QXSI-2198372-12">

I have inputs that are longer than 30 characters so I wanted to know what is the way to automate changing the element attribute before using selenium .sendkeys in that field.

I have checked a similar question but it's not really helping me

Thank you

asked Oct 30, 2020 at 12:52
1
  • That's not how websites work. Those max lengths were put into the site for a reason. Yes, you could increase the max lengths that you could submit but it's also likely that you will cause problems because the site isn't expecting that much data. Problems could range from no issues to the data may be cut off anyway to crashes and errors. Commented Oct 30, 2020 at 14:15

1 Answer 1

1

You could try to change maxlength value by executing javascript:

driver.execute_script("arguments[0].setAttribute('maxlength', 100)", element)

But there is high probability that field value is validated not only using this attribute, but using javascript framework as well as on backend. Changing maxlength value may allow to enter some long value into the input field, but does not guarantee, that this value will be handled by the website.

answered Oct 30, 2020 at 13:04

1 Comment

luckily, it's not handled by the website. Thank you

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.