Reputation: 11
The code which i have written to send the an array list to a text-box in my internal site. Where the input to array is from excel.
value = [] // ArrayList
while len(value)<1000:
Data=sheet.row(loop)
T1 = Data[1].value
T2=int(T1) // to remove float values
T2 = str(T2) // as the text-box is only accepting the strings
value.append(T2)
loop += 1 //to read the next row in the excel sheet.
driver.find_element_by_xpath('//*[@id="operand.action_(id=7)"]').send_keys(values[0:])
Format of values sending to text-box is: ['40554666', '40554539', '40554762', '40554806']
This is giving me an error because the above code is sending the values to the text-box in a wrong format where i need to remove " '' " and " [] " The Text-box can only take the numbers separated by comma or numbers in new line.
Note : I have tried to send one element at a time but that is not effective solution for my site. That is the reason i am trying to send 1k values at a time.
Can someone please help me here ?
Upvotes: 1
Views: 1335
Reputation: 25686
That's what an array of string looks like when you print the array itself in python. You need to loop through the array use one element at a time.
mylist = ['1','2','3']
print(mylist)
This prints ['1', '2', '3']
You want
for list_item in mylist:
print(list_item)
and that prints
1
2
3
More specifically
for list_item in mylist:
...
driver.find_element_by_xpath('//*[@id="operand.action_(id=7)"]').send_keys(list_item)
Side note: If all you are using is the ID, why use XPath? Just use
driver.find_element_by_id('operand.action_(id=7)')
Upvotes: 1