Making several Request with Devtools

41 views
Skip to first unread message

Jose Carias

unread,
Oct 30, 2020, 7:22:22 PM10/30/20
to Chrome DevTools

I am trying to making dynamic consults through "for loop" on a website, once the information is in the text box, I use Document.getElementById ("link").Click() to making the query and get the desired information from what I enter in the text box dynamically.

Something like that:

the problem is then when I run the code, I only get a response from the last element of the "for loop". It's like document.getElementById("consult").click() did not execute for all the elements of the array.

Any suggestion?

PhistucK

unread,
Oct 30, 2020, 7:23:37 PM10/30/20
to Google Chrome Developer Tools
Can you provide some test code that shows the issue?

PhistucK


--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/7b8ab338-46fb-4821-a13d-5b238039c26bn%40googlegroups.com.

Jose Acosta

unread,
Oct 30, 2020, 7:49:52 PM10/30/20
to google-chrome-...@googlegroups.com

Yes:

 

var id = ["13454" , "134547", "1348878"];
for(i=0;i<id.length;i++){
document.getElementById("ParameterBox").value = id[i];
document.getElementById("consult").click();
var result = document.getElementById("result").value;
console.log(result);
}

 

 

 

De: PhistucK
Enviado: viernes 30 de octubre de 2020 05:23
Para: Google Chrome Developer Tools
Asunto: Re: [Chrome DevTools] Making several Request with Devtools

 

Can you provide some test code that shows the issue?

 

PhistucK

 

 

On Sat, Oct 31, 2020 at 1:22 AM Jose Carias <josephthene...@gmail.com> wrote:

I am trying to making dynamic consults through "for loop" on a website, once the information is in the text box, I use Document.getElementById ("link").Click() to making the query and get the desired information from what I enter in the text box dynamically.

Something like that:

the problem is then when I run the code, I only get a response from the last element of the "for loop". It's like document.getElementById("consult").click() did not execute for all the elements of the array.

Any suggestion?

--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/7b8ab338-46fb-4821-a13d-5b238039c26bn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.

guest271314

unread,
Oct 30, 2020, 8:11:07 PM10/30/20
to google-chrome-...@googlegroups.com
If the code within the loop performs any asynchronous operations for loop does not await completion of the task. You can pass the variable to an IIFE to maintain a reference to the current variable, or utilize Promise.all() and, or async and await to await completion of all the procedures expected to be completed in the for loop.

PhistucK

unread,
Oct 30, 2020, 8:24:24 PM10/30/20
to Google Chrome Developer Tools
And does this code behave differently when it is run as part of the website versus when it is run in the Developer Tools?
If it behaves the same, this is not the right place for this question (stackoverflow.com might be better).

PhistucK


Jose Acosta

unread,
Oct 30, 2020, 9:15:19 PM10/30/20
to google-chrome-...@googlegroups.com

okay, just to put them in context. I am trying to do this because in my work I have to look for a client code that is obtained by entering the id in a web tool that returns the code I need.

So I have to be doing this hundreds of times every day. I am trying to find a way to do it in an automated way by entering javascript code to the console in devtools of google chrome, but when I run the code (using debbuger;) I see that when the for loop is crossed the elements entered into the box of text are put satisfactorily but when making the query (clicking) it does so at the end of the for loop.

In the example shown, three IDs are traversed, and the query of the three IDs does them until the for loop ends, and I need you to do them in a sychronous way to save the client code in the variable.

 

 

 

De: guest271314
Enviado: viernes 30 de octubre de 2020 06:11
Para: google-chrome-...@googlegroups.com
Asunto: Re: [Chrome DevTools] Making several Request with Devtools

 

If the code within the loop performs any asynchronous operations for loop does not await completion of the task. You can pass the variable to an IIFE to maintain a reference to the current variable, or utilize Promise.all() and, or async and await to await completion of all the procedures expected to be completed in the for loop.

 

On Fri, Oct 30, 2020 at 4:23 PM PhistucK <phis...@gmail.com> wrote:

Can you provide some test code that shows the issue?

 

PhistucK

 

 

On Sat, Oct 31, 2020 at 1:22 AM Jose Carias <josephthene...@gmail.com> wrote:

I am trying to making dynamic consults through "for loop" on a website, once the information is in the text box, I use Document.getElementById ("link").Click() to making the query and get the desired information from what I enter in the text box dynamically.

Something like that:

the problem is then when I run the code, I only get a response from the last element of the "for loop". It's like document.getElementById("consult").click() did not execute for all the elements of the array.

Any suggestion?

--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/7b8ab338-46fb-4821-a13d-5b238039c26bn%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/CABc02_KYL3B4w4V1%2B5xmviSiTJwNsv9P00gKHN2-jJ4DVW%2B9fg%40mail.gmail.com.

--
You received this message because you are subscribed to the Google Groups "Chrome DevTools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.

PhistucK

unread,
Oct 31, 2020, 5:01:15 AM10/31/20
to Google Chrome Developer Tools
I think this is out of scope for this group... Sorry.

PhistucK


Reply all
Reply to author
Forward
0 new messages