How to send Array to a text box with Python selenium scripting?
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 ?
arrays python-3.x selenium
add a comment |
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 ?
arrays python-3.x selenium
It looks to me like you need to format your string.
– Brian
Nov 26 '18 at 19:07
Can we use formatting in send_keys() function??
– naveen sai
Nov 27 '18 at 3:57
Hi Brian, Thanks for your comment and becoz of it an idea strikes to my mind to resolved the issue.
– naveen sai
Nov 29 '18 at 14:29
add a comment |
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 ?
arrays python-3.x selenium
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 ?
arrays python-3.x selenium
arrays python-3.x selenium
edited Nov 27 '18 at 3:56
naveen sai
asked Nov 26 '18 at 18:31
naveen sainaveen sai
13
13
It looks to me like you need to format your string.
– Brian
Nov 26 '18 at 19:07
Can we use formatting in send_keys() function??
– naveen sai
Nov 27 '18 at 3:57
Hi Brian, Thanks for your comment and becoz of it an idea strikes to my mind to resolved the issue.
– naveen sai
Nov 29 '18 at 14:29
add a comment |
It looks to me like you need to format your string.
– Brian
Nov 26 '18 at 19:07
Can we use formatting in send_keys() function??
– naveen sai
Nov 27 '18 at 3:57
Hi Brian, Thanks for your comment and becoz of it an idea strikes to my mind to resolved the issue.
– naveen sai
Nov 29 '18 at 14:29
It looks to me like you need to format your string.
– Brian
Nov 26 '18 at 19:07
It looks to me like you need to format your string.
– Brian
Nov 26 '18 at 19:07
Can we use formatting in send_keys() function??
– naveen sai
Nov 27 '18 at 3:57
Can we use formatting in send_keys() function??
– naveen sai
Nov 27 '18 at 3:57
Hi Brian, Thanks for your comment and becoz of it an idea strikes to my mind to resolved the issue.
– naveen sai
Nov 29 '18 at 14:29
Hi Brian, Thanks for your comment and becoz of it an idea strikes to my mind to resolved the issue.
– naveen sai
Nov 29 '18 at 14:29
add a comment |
1 Answer
1
active
oldest
votes
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)')
The looping I have tried already and it is not effective n slow for my website. That is the reason i am trying to send 1k values at a time. Is there any way to send formated values of array to the texbox??
– naveen sai
Nov 27 '18 at 3:54
I'm not sure what you are trying to do... you are trying to send a comma-delimited list of the array elements? e.g. if the array is['1','2','3']you want to send what?1,2,3?
– JeffC
Nov 27 '18 at 16:32
Yes, i am able to achieve it by using join. Here is the details: driver.find_element_by_xpath('//*@id="operand.action_(id=7)"]').send_keys(','.join(value)) But getting an error: selenium.common.exceptions.WebDriverException: Message: Failed to convert data to an object Can you please help me here to understand why i am getting this error and how to resolve it ?
– naveen sai
Nov 28 '18 at 11:08
Runtest = ','.join(value)and see what goes intotest. Make sure it's1,2,3or whatever like you expect. It sounds like it's not.
– JeffC
Nov 28 '18 at 15:10
Hi Jeff, Somehow after a restart it started working fine. I am really Thank you for your time and response.
– naveen sai
Nov 29 '18 at 14:27
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53487048%2fhow-to-send-array-to-a-text-box-with-python-selenium-scripting%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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)')
The looping I have tried already and it is not effective n slow for my website. That is the reason i am trying to send 1k values at a time. Is there any way to send formated values of array to the texbox??
– naveen sai
Nov 27 '18 at 3:54
I'm not sure what you are trying to do... you are trying to send a comma-delimited list of the array elements? e.g. if the array is['1','2','3']you want to send what?1,2,3?
– JeffC
Nov 27 '18 at 16:32
Yes, i am able to achieve it by using join. Here is the details: driver.find_element_by_xpath('//*@id="operand.action_(id=7)"]').send_keys(','.join(value)) But getting an error: selenium.common.exceptions.WebDriverException: Message: Failed to convert data to an object Can you please help me here to understand why i am getting this error and how to resolve it ?
– naveen sai
Nov 28 '18 at 11:08
Runtest = ','.join(value)and see what goes intotest. Make sure it's1,2,3or whatever like you expect. It sounds like it's not.
– JeffC
Nov 28 '18 at 15:10
Hi Jeff, Somehow after a restart it started working fine. I am really Thank you for your time and response.
– naveen sai
Nov 29 '18 at 14:27
add a comment |
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)')
The looping I have tried already and it is not effective n slow for my website. That is the reason i am trying to send 1k values at a time. Is there any way to send formated values of array to the texbox??
– naveen sai
Nov 27 '18 at 3:54
I'm not sure what you are trying to do... you are trying to send a comma-delimited list of the array elements? e.g. if the array is['1','2','3']you want to send what?1,2,3?
– JeffC
Nov 27 '18 at 16:32
Yes, i am able to achieve it by using join. Here is the details: driver.find_element_by_xpath('//*@id="operand.action_(id=7)"]').send_keys(','.join(value)) But getting an error: selenium.common.exceptions.WebDriverException: Message: Failed to convert data to an object Can you please help me here to understand why i am getting this error and how to resolve it ?
– naveen sai
Nov 28 '18 at 11:08
Runtest = ','.join(value)and see what goes intotest. Make sure it's1,2,3or whatever like you expect. It sounds like it's not.
– JeffC
Nov 28 '18 at 15:10
Hi Jeff, Somehow after a restart it started working fine. I am really Thank you for your time and response.
– naveen sai
Nov 29 '18 at 14:27
add a comment |
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)')
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)')
answered Nov 26 '18 at 19:55
JeffCJeffC
12.5k41533
12.5k41533
The looping I have tried already and it is not effective n slow for my website. That is the reason i am trying to send 1k values at a time. Is there any way to send formated values of array to the texbox??
– naveen sai
Nov 27 '18 at 3:54
I'm not sure what you are trying to do... you are trying to send a comma-delimited list of the array elements? e.g. if the array is['1','2','3']you want to send what?1,2,3?
– JeffC
Nov 27 '18 at 16:32
Yes, i am able to achieve it by using join. Here is the details: driver.find_element_by_xpath('//*@id="operand.action_(id=7)"]').send_keys(','.join(value)) But getting an error: selenium.common.exceptions.WebDriverException: Message: Failed to convert data to an object Can you please help me here to understand why i am getting this error and how to resolve it ?
– naveen sai
Nov 28 '18 at 11:08
Runtest = ','.join(value)and see what goes intotest. Make sure it's1,2,3or whatever like you expect. It sounds like it's not.
– JeffC
Nov 28 '18 at 15:10
Hi Jeff, Somehow after a restart it started working fine. I am really Thank you for your time and response.
– naveen sai
Nov 29 '18 at 14:27
add a comment |
The looping I have tried already and it is not effective n slow for my website. That is the reason i am trying to send 1k values at a time. Is there any way to send formated values of array to the texbox??
– naveen sai
Nov 27 '18 at 3:54
I'm not sure what you are trying to do... you are trying to send a comma-delimited list of the array elements? e.g. if the array is['1','2','3']you want to send what?1,2,3?
– JeffC
Nov 27 '18 at 16:32
Yes, i am able to achieve it by using join. Here is the details: driver.find_element_by_xpath('//*@id="operand.action_(id=7)"]').send_keys(','.join(value)) But getting an error: selenium.common.exceptions.WebDriverException: Message: Failed to convert data to an object Can you please help me here to understand why i am getting this error and how to resolve it ?
– naveen sai
Nov 28 '18 at 11:08
Runtest = ','.join(value)and see what goes intotest. Make sure it's1,2,3or whatever like you expect. It sounds like it's not.
– JeffC
Nov 28 '18 at 15:10
Hi Jeff, Somehow after a restart it started working fine. I am really Thank you for your time and response.
– naveen sai
Nov 29 '18 at 14:27
The looping I have tried already and it is not effective n slow for my website. That is the reason i am trying to send 1k values at a time. Is there any way to send formated values of array to the texbox??
– naveen sai
Nov 27 '18 at 3:54
The looping I have tried already and it is not effective n slow for my website. That is the reason i am trying to send 1k values at a time. Is there any way to send formated values of array to the texbox??
– naveen sai
Nov 27 '18 at 3:54
I'm not sure what you are trying to do... you are trying to send a comma-delimited list of the array elements? e.g. if the array is
['1','2','3'] you want to send what? 1,2,3?– JeffC
Nov 27 '18 at 16:32
I'm not sure what you are trying to do... you are trying to send a comma-delimited list of the array elements? e.g. if the array is
['1','2','3'] you want to send what? 1,2,3?– JeffC
Nov 27 '18 at 16:32
Yes, i am able to achieve it by using join. Here is the details: driver.find_element_by_xpath('//*@id="operand.action_(id=7)"]').send_keys(','.join(value)) But getting an error: selenium.common.exceptions.WebDriverException: Message: Failed to convert data to an object Can you please help me here to understand why i am getting this error and how to resolve it ?
– naveen sai
Nov 28 '18 at 11:08
Yes, i am able to achieve it by using join. Here is the details: driver.find_element_by_xpath('//*@id="operand.action_(id=7)"]').send_keys(','.join(value)) But getting an error: selenium.common.exceptions.WebDriverException: Message: Failed to convert data to an object Can you please help me here to understand why i am getting this error and how to resolve it ?
– naveen sai
Nov 28 '18 at 11:08
Run
test = ','.join(value) and see what goes into test. Make sure it's 1,2,3 or whatever like you expect. It sounds like it's not.– JeffC
Nov 28 '18 at 15:10
Run
test = ','.join(value) and see what goes into test. Make sure it's 1,2,3 or whatever like you expect. It sounds like it's not.– JeffC
Nov 28 '18 at 15:10
Hi Jeff, Somehow after a restart it started working fine. I am really Thank you for your time and response.
– naveen sai
Nov 29 '18 at 14:27
Hi Jeff, Somehow after a restart it started working fine. I am really Thank you for your time and response.
– naveen sai
Nov 29 '18 at 14:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53487048%2fhow-to-send-array-to-a-text-box-with-python-selenium-scripting%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It looks to me like you need to format your string.
– Brian
Nov 26 '18 at 19:07
Can we use formatting in send_keys() function??
– naveen sai
Nov 27 '18 at 3:57
Hi Brian, Thanks for your comment and becoz of it an idea strikes to my mind to resolved the issue.
– naveen sai
Nov 29 '18 at 14:29