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
-
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.JeffC– JeffC2020年10月30日 14:15:34 +00:00Commented Oct 30, 2020 at 14:15
1 Answer 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.